config

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package config provides application configuration.

Package config provides application configuration.

Index

Constants

View Source
const (
	DefaultHost                      = "0.0.0.0"
	DefaultPort                      = 8080
	DefaultLogLevel                  = "INFO"
	DefaultWorkerCount               = 1
	DefaultSearchLimit               = 10
	DefaultCloneSubdir               = "repos"
	DefaultEndpointParallelTasks     = 1
	DefaultEndpointTimeout           = 60 * time.Second
	DefaultEndpointMaxRetries        = 5
	DefaultEndpointInitialDelay      = 2 * time.Second
	DefaultEndpointBackoffFactor     = 2.0
	DefaultEndpointMaxTokens         = 4000
	DefaultPeriodicSyncInterval      = 1800.0 // seconds
	DefaultPeriodicSyncCheckInterval = 10.0   // seconds
	DefaultPeriodicSyncRetries       = 3
	DefaultEndpointMaxBatchChars     = 16000
	DefaultEndpointMaxBatchSize      = 1
	DefaultRemoteTimeout             = 30 * time.Second
	DefaultRemoteMaxRetries          = 3
	DefaultReportingInterval         = 5 * time.Second
)

Default configuration values.

Variables

This section is empty.

Functions

func DefaultCloneDir

func DefaultCloneDir(dataDir string) string

DefaultCloneDir returns the default clone directory for a given data directory.

func DefaultDataDir

func DefaultDataDir() string

DefaultDataDir returns the default data directory.

func DefaultLogger

func DefaultLogger() *slog.Logger

DefaultLogger returns the default slog logger for library consumers.

func LoadDotEnv

func LoadDotEnv(path string) error

LoadDotEnv loads environment variables from a .env file. If path is empty, it loads from ".env" in the current directory. If the file does not exist, it silently returns nil (not an error).

func LoadDotEnvFromFiles

func LoadDotEnvFromFiles(paths ...string) error

LoadDotEnvFromFiles loads environment variables from multiple .env files. Files are processed in order. Note: godotenv.Load does NOT override existing environment variables - the first file that sets a variable wins. Non-existent files are silently skipped.

func MustLoadDotEnv

func MustLoadDotEnv(path string) error

MustLoadDotEnv loads environment variables from a .env file. Unlike LoadDotEnv, it returns an error if the file does not exist.

func OverloadDotEnvFromFiles

func OverloadDotEnvFromFiles(paths ...string) error

OverloadDotEnvFromFiles loads environment variables from multiple .env files, overwriting any existing values. Files are processed in order, with later files overwriting earlier values. Non-existent files are silently skipped.

func ParseAPIKeys

func ParseAPIKeys(s string) []string

ParseAPIKeys parses a comma-separated string of API keys.

func PrepareCloneDir

func PrepareCloneDir(cloneDir, dataDir string) (string, error)

PrepareCloneDir resolves the clone directory (defaulting if empty) and creates it.

func PrepareDataDir

func PrepareDataDir(dataDir string) (string, error)

PrepareDataDir creates the data directory if it does not exist and returns it.

Types

type AppConfig

type AppConfig struct {
	// contains filtered or unexported fields
}

AppConfig holds the main application configuration.

func LoadConfig

func LoadConfig(envPath string) (AppConfig, error)

LoadConfig loads configuration from a .env file (optional) and environment variables. The .env file is loaded first if it exists, then environment variables override. This matches Python's pydantic-settings behavior.

func NewAppConfig

func NewAppConfig() AppConfig

NewAppConfig creates a new AppConfig with defaults.

func NewAppConfigWithOptions

func NewAppConfigWithOptions(opts ...AppConfigOption) AppConfig

NewAppConfigWithOptions creates an AppConfig with functional options.

func (AppConfig) APIKeys

func (c AppConfig) APIKeys() []string

APIKeys returns the configured API keys.

func (AppConfig) Addr

func (c AppConfig) Addr() string

Addr returns the combined host:port address.

func (AppConfig) Apply

func (c AppConfig) Apply(opts ...AppConfigOption) AppConfig

Apply returns a new AppConfig with the given options applied. This copies all fields from the receiver and then applies the options, making it safe to use when adding new fields to AppConfig.

func (AppConfig) ChunkMinSize

func (c AppConfig) ChunkMinSize() int

ChunkMinSize returns the minimum chunk size in characters.

func (AppConfig) ChunkOverlap

func (c AppConfig) ChunkOverlap() int

ChunkOverlap returns the overlap between adjacent chunks in characters.

func (AppConfig) ChunkSize

func (c AppConfig) ChunkSize() int

ChunkSize returns the target chunk size in characters.

func (AppConfig) CloneDir

func (c AppConfig) CloneDir() string

CloneDir returns the clone directory path.

func (AppConfig) DBURL

func (c AppConfig) DBURL() string

DBURL returns the database connection URL.

func (AppConfig) DataDir

func (c AppConfig) DataDir() string

DataDir returns the data directory path.

func (AppConfig) DisableTelemetry

func (c AppConfig) DisableTelemetry() bool

DisableTelemetry returns whether telemetry is disabled.

func (AppConfig) EmbeddingEndpoint

func (c AppConfig) EmbeddingEndpoint() *Endpoint

EmbeddingEndpoint returns the embedding endpoint config.

func (AppConfig) EnrichmentEndpoint

func (c AppConfig) EnrichmentEndpoint() *Endpoint

EnrichmentEndpoint returns the enrichment endpoint config.

func (AppConfig) EnsureCloneDir

func (c AppConfig) EnsureCloneDir() error

EnsureCloneDir creates the clone directory if it doesn't exist.

func (AppConfig) EnsureDataDir

func (c AppConfig) EnsureDataDir() error

EnsureDataDir creates the data directory if it doesn't exist.

func (AppConfig) EnsureLiteLLMCacheDir

func (c AppConfig) EnsureLiteLLMCacheDir() error

EnsureLiteLLMCacheDir creates the LiteLLM cache directory if it doesn't exist.

func (AppConfig) HTTPCacheDir

func (c AppConfig) HTTPCacheDir() string

HTTPCacheDir returns the HTTP response cache directory, or empty if disabled.

func (AppConfig) Host

func (c AppConfig) Host() string

Host returns the server host to bind to.

func (AppConfig) IsRemote

func (c AppConfig) IsRemote() bool

IsRemote returns true if running in remote mode.

func (AppConfig) LiteLLMCache

func (c AppConfig) LiteLLMCache() LiteLLMCacheConfig

LiteLLMCache returns the LiteLLM cache config.

func (AppConfig) LiteLLMCacheDir

func (c AppConfig) LiteLLMCacheDir() string

LiteLLMCacheDir returns the LiteLLM cache directory path.

func (AppConfig) LogAttrs

func (c AppConfig) LogAttrs() []slog.Attr

LogAttrs returns slog attributes for logging the configuration. Sensitive values like API keys are masked or shown as counts.

func (AppConfig) LogFormat

func (c AppConfig) LogFormat() LogFormat

LogFormat returns the log format.

func (AppConfig) LogLevel

func (c AppConfig) LogLevel() string

LogLevel returns the log level.

func (AppConfig) PeriodicSync

func (c AppConfig) PeriodicSync() PeriodicSyncConfig

PeriodicSync returns the periodic sync config.

func (AppConfig) Port

func (c AppConfig) Port() int

Port returns the server port to listen on.

func (AppConfig) Remote

func (c AppConfig) Remote() RemoteConfig

Remote returns the remote config.

func (AppConfig) Reporting

func (c AppConfig) Reporting() ReportingConfig

Reporting returns the reporting config.

func (AppConfig) SearchLimit

func (c AppConfig) SearchLimit() int

SearchLimit returns the default search result limit.

func (AppConfig) SimpleChunking

func (c AppConfig) SimpleChunking() bool

SimpleChunking returns whether fixed-size text chunking is enabled.

func (AppConfig) SkipProviderValidation

func (c AppConfig) SkipProviderValidation() bool

SkipProviderValidation returns whether to skip provider validation at startup. This is intended for testing only.

func (AppConfig) WorkerCount

func (c AppConfig) WorkerCount() int

WorkerCount returns the number of background workers.

type AppConfigOption

type AppConfigOption func(*AppConfig)

AppConfigOption is a functional option for AppConfig.

func WithAPIKeys

func WithAPIKeys(keys []string) AppConfigOption

WithAPIKeys sets the API keys.

func WithChunkMinSize

func WithChunkMinSize(minSize int) AppConfigOption

WithChunkMinSize sets the minimum chunk size in characters.

func WithChunkOverlap

func WithChunkOverlap(overlap int) AppConfigOption

WithChunkOverlap sets the overlap between adjacent chunks in characters.

func WithChunkSize

func WithChunkSize(size int) AppConfigOption

WithChunkSize sets the target chunk size in characters.

func WithDBURL

func WithDBURL(url string) AppConfigOption

WithDBURL sets the database URL.

func WithDataDir

func WithDataDir(dir string) AppConfigOption

WithDataDir sets the data directory.

func WithDisableTelemetry

func WithDisableTelemetry(disabled bool) AppConfigOption

WithDisableTelemetry sets telemetry state.

func WithEmbeddingEndpoint

func WithEmbeddingEndpoint(e Endpoint) AppConfigOption

WithEmbeddingEndpoint sets the embedding endpoint.

func WithEnrichmentEndpoint

func WithEnrichmentEndpoint(e Endpoint) AppConfigOption

WithEnrichmentEndpoint sets the enrichment endpoint.

func WithHTTPCacheDir

func WithHTTPCacheDir(dir string) AppConfigOption

WithHTTPCacheDir sets the HTTP response cache directory.

func WithHost

func WithHost(host string) AppConfigOption

WithHost sets the server host.

func WithLiteLLMCacheConfig

func WithLiteLLMCacheConfig(l LiteLLMCacheConfig) AppConfigOption

WithLiteLLMCacheConfig sets the LiteLLM cache config.

func WithLogFormat

func WithLogFormat(format LogFormat) AppConfigOption

WithLogFormat sets the log format.

func WithLogLevel

func WithLogLevel(level string) AppConfigOption

WithLogLevel sets the log level.

func WithPeriodicSyncConfig

func WithPeriodicSyncConfig(p PeriodicSyncConfig) AppConfigOption

WithPeriodicSyncConfig sets the periodic sync config.

func WithPort

func WithPort(port int) AppConfigOption

WithPort sets the server port.

func WithRemoteConfig

func WithRemoteConfig(r RemoteConfig) AppConfigOption

WithRemoteConfig sets the remote config.

func WithReportingConfig

func WithReportingConfig(r ReportingConfig) AppConfigOption

WithReportingConfig sets the reporting config.

func WithSearchLimit

func WithSearchLimit(n int) AppConfigOption

WithSearchLimit sets the default search result limit.

func WithSimpleChunking

func WithSimpleChunking(enabled bool) AppConfigOption

WithSimpleChunking enables or disables fixed-size text chunking.

func WithSkipProviderValidation

func WithSkipProviderValidation(skip bool) AppConfigOption

WithSkipProviderValidation sets whether to skip provider validation. WARNING: For testing only. Kodit requires providers for full functionality.

func WithWorkerCount

func WithWorkerCount(n int) AppConfigOption

WithWorkerCount sets the number of background workers.

type Endpoint

type Endpoint struct {
	// contains filtered or unexported fields
}

Endpoint configures an AI service endpoint.

func NewEndpoint

func NewEndpoint() Endpoint

NewEndpoint creates a new Endpoint with defaults.

func NewEndpointWithOptions

func NewEndpointWithOptions(opts ...EndpointOption) Endpoint

NewEndpointWithOptions creates an Endpoint with functional options.

func (Endpoint) APIKey

func (e Endpoint) APIKey() string

APIKey returns the API key.

func (Endpoint) BackoffFactor

func (e Endpoint) BackoffFactor() float64

BackoffFactor returns the retry backoff multiplier.

func (Endpoint) BaseURL

func (e Endpoint) BaseURL() string

BaseURL returns the base URL for the endpoint.

func (Endpoint) ExtraParams

func (e Endpoint) ExtraParams() map[string]any

ExtraParams returns additional provider-specific parameters.

func (Endpoint) InitialDelay

func (e Endpoint) InitialDelay() time.Duration

InitialDelay returns the initial retry delay.

func (Endpoint) IsConfigured

func (e Endpoint) IsConfigured() bool

IsConfigured returns true if the endpoint has required configuration.

func (Endpoint) MaxBatchChars

func (e Endpoint) MaxBatchChars() int

MaxBatchChars returns the maximum total characters per embedding batch.

func (Endpoint) MaxBatchSize

func (e Endpoint) MaxBatchSize() int

MaxBatchSize returns the maximum number of requests per batch.

func (Endpoint) MaxRetries

func (e Endpoint) MaxRetries() int

MaxRetries returns the maximum retry count.

func (Endpoint) MaxTokens

func (e Endpoint) MaxTokens() int

MaxTokens returns the maximum token limit.

func (Endpoint) Model

func (e Endpoint) Model() string

Model returns the model identifier.

func (Endpoint) NumParallelTasks

func (e Endpoint) NumParallelTasks() int

NumParallelTasks returns the number of parallel tasks.

func (Endpoint) SocketPath

func (e Endpoint) SocketPath() string

SocketPath returns the Unix socket path.

func (Endpoint) Timeout

func (e Endpoint) Timeout() time.Duration

Timeout returns the request timeout.

type EndpointEnv

type EndpointEnv struct {
	// BaseURL is the base URL for the endpoint.
	// Env: *_BASE_URL
	BaseURL string `envconfig:"BASE_URL"`

	// Model is the model identifier (e.g., openai/text-embedding-3-small).
	// Env: *_MODEL
	Model string `envconfig:"MODEL"`

	// APIKey is the API key for authentication.
	// Env: *_API_KEY
	APIKey string `envconfig:"API_KEY"`

	// NumParallelTasks is the number of parallel tasks.
	// Env: *_NUM_PARALLEL_TASKS (default: 1)
	NumParallelTasks int `envconfig:"NUM_PARALLEL_TASKS" default:"1"`

	// SocketPath is the Unix socket path for local communication.
	// Env: *_SOCKET_PATH
	SocketPath string `envconfig:"SOCKET_PATH"`

	// Timeout is the request timeout in seconds.
	// Env: *_TIMEOUT (default: 60)
	Timeout float64 `envconfig:"TIMEOUT" default:"60"`

	// MaxRetries is the maximum number of retries.
	// Env: *_MAX_RETRIES (default: 5)
	MaxRetries int `envconfig:"MAX_RETRIES" default:"5"`

	// InitialDelay is the initial retry delay in seconds.
	// Env: *_INITIAL_DELAY (default: 2.0)
	InitialDelay float64 `envconfig:"INITIAL_DELAY" default:"2.0"`

	// BackoffFactor is the retry backoff multiplier.
	// Env: *_BACKOFF_FACTOR (default: 2.0)
	BackoffFactor float64 `envconfig:"BACKOFF_FACTOR" default:"2.0"`

	// ExtraParams is a JSON-encoded map of extra parameters.
	// Env: *_EXTRA_PARAMS
	ExtraParams string `envconfig:"EXTRA_PARAMS"`

	// MaxTokens is the maximum token limit.
	// Env: *_MAX_TOKENS (default: 4000)
	MaxTokens int `envconfig:"MAX_TOKENS" default:"4000"`

	// MaxBatchChars is the maximum total characters per embedding batch.
	// Env: *_MAX_BATCH_CHARS (default: 16000)
	MaxBatchChars int `envconfig:"MAX_BATCH_CHARS" default:"16000"`

	// MaxBatchSize is the maximum number of requests per batch.
	// Env: *_MAX_BATCH_SIZE (default: 1)
	MaxBatchSize int `envconfig:"MAX_BATCH_SIZE" default:"1"`
}

EndpointEnv holds environment configuration for an AI endpoint.

func (EndpointEnv) IsConfigured

func (e EndpointEnv) IsConfigured() bool

IsConfigured returns true if the endpoint has a model configured.

func (EndpointEnv) ToEndpoint

func (e EndpointEnv) ToEndpoint() Endpoint

ToEndpoint converts EndpointEnv to Endpoint.

type EndpointOption

type EndpointOption func(*Endpoint)

EndpointOption is a functional option for Endpoint.

func WithAPIKey

func WithAPIKey(key string) EndpointOption

WithAPIKey sets the API key.

func WithBackoffFactor

func WithBackoffFactor(f float64) EndpointOption

WithBackoffFactor sets the retry backoff multiplier.

func WithBaseURL

func WithBaseURL(url string) EndpointOption

WithBaseURL sets the base URL.

func WithExtraParams

func WithExtraParams(params map[string]any) EndpointOption

WithExtraParams sets extra provider parameters.

func WithInitialDelay

func WithInitialDelay(d time.Duration) EndpointOption

WithInitialDelay sets the initial retry delay.

func WithMaxBatchChars

func WithMaxBatchChars(n int) EndpointOption

WithMaxBatchChars sets the maximum total characters per embedding batch.

func WithMaxBatchSize

func WithMaxBatchSize(n int) EndpointOption

WithMaxBatchSize sets the maximum number of requests per batch.

func WithMaxRetries

func WithMaxRetries(n int) EndpointOption

WithMaxRetries sets the maximum retry count.

func WithMaxTokens

func WithMaxTokens(n int) EndpointOption

WithMaxTokens sets the maximum token limit.

func WithModel

func WithModel(model string) EndpointOption

WithModel sets the model.

func WithNumParallelTasks

func WithNumParallelTasks(n int) EndpointOption

WithNumParallelTasks sets the parallel task count.

func WithSocketPath

func WithSocketPath(path string) EndpointOption

WithSocketPath sets the Unix socket path.

func WithTimeout

func WithTimeout(d time.Duration) EndpointOption

WithTimeout sets the request timeout.

type EnvConfig

type EnvConfig struct {
	// Host is the server host to bind to.
	// Env: HOST (default: 0.0.0.0)
	Host string `envconfig:"HOST" default:"0.0.0.0"`

	// Port is the server port to listen on.
	// Env: PORT (default: 8080)
	Port int `envconfig:"PORT" default:"8080"`

	// DataDir is the data directory path.
	// Env: DATA_DIR
	// Default: ~/.kodit
	DataDir string `envconfig:"DATA_DIR"`

	// DBURL is the database connection URL.
	// Env: DB_URL
	// Default: sqlite:///{data_dir}/kodit.db
	DBURL string `envconfig:"DB_URL"`

	// LogLevel is the log verbosity level.
	// Env: LOG_LEVEL (default: INFO)
	LogLevel string `envconfig:"LOG_LEVEL" default:"INFO"`

	// LogFormat is the log output format (pretty or json).
	// Env: LOG_FORMAT (default: pretty)
	LogFormat string `envconfig:"LOG_FORMAT" default:"pretty"`

	// DisableTelemetry controls telemetry collection.
	// Env: DISABLE_TELEMETRY (default: false)
	DisableTelemetry bool `envconfig:"DISABLE_TELEMETRY" default:"false"`

	// SkipProviderValidation skips provider requirement validation at startup.
	// Env: SKIP_PROVIDER_VALIDATION (default: false)
	// WARNING: For testing only. Kodit requires providers for full functionality.
	SkipProviderValidation bool `envconfig:"SKIP_PROVIDER_VALIDATION" default:"false"`

	// APIKeys is a comma-separated list of valid API keys.
	// Env: API_KEYS
	APIKeys string `envconfig:"API_KEYS"`

	// EmbeddingEndpoint configures the embedding AI service.
	EmbeddingEndpoint EndpointEnv `envconfig:"EMBEDDING_ENDPOINT"`

	// EnrichmentEndpoint configures the enrichment AI service.
	EnrichmentEndpoint EndpointEnv `envconfig:"ENRICHMENT_ENDPOINT"`

	// PeriodicSync configures periodic repository syncing.
	PeriodicSync PeriodicSyncEnv `envconfig:"PERIODIC_SYNC"`

	// Remote configures remote server connection.
	Remote RemoteEnv `envconfig:"REMOTE"`

	// Reporting configures progress reporting.
	Reporting ReportingEnv `envconfig:"REPORTING"`

	// LiteLLMCache configures LLM response caching.
	LiteLLMCache LiteLLMCacheEnv `envconfig:"LITELLM_CACHE"`

	// WorkerCount is the number of background workers.
	// Env: WORKER_COUNT (default: 1)
	WorkerCount int `envconfig:"WORKER_COUNT" default:"1"`

	// SearchLimit is the default search result limit.
	// Env: SEARCH_LIMIT (default: 10)
	SearchLimit int `envconfig:"SEARCH_LIMIT" default:"10"`

	// HTTPCacheDir is the directory for caching HTTP responses to disk.
	// When set, POST request/response pairs are cached to avoid repeated API calls.
	// Env: HTTP_CACHE_DIR
	HTTPCacheDir string `envconfig:"HTTP_CACHE_DIR"`

	// SimpleChunking enables fixed-size text chunking instead of AST-based snippet extraction.
	// Env: SIMPLE_CHUNKING_ENABLED (default: true)
	SimpleChunking bool `envconfig:"SIMPLE_CHUNKING_ENABLED" default:"true"`

	// ChunkSize is the target size in characters for each text chunk.
	// Env: CHUNK_SIZE (default: 1500)
	ChunkSize int `envconfig:"CHUNK_SIZE" default:"1500"`

	// ChunkOverlap is the number of overlapping characters between adjacent chunks.
	// Env: CHUNK_OVERLAP (default: 200)
	ChunkOverlap int `envconfig:"CHUNK_OVERLAP" default:"200"`

	// ChunkMinSize is the minimum chunk size in characters; smaller chunks are dropped.
	// Env: CHUNK_MIN_SIZE (default: 50)
	ChunkMinSize int `envconfig:"CHUNK_MIN_SIZE" default:"50"`
}

EnvConfig holds all environment-based configuration. Field names map to environment variables with KODIT_ prefix removed. Nested structs use underscore delimiter (e.g., EMBEDDING_ENDPOINT_BASE_URL).

func LoadFromEnv

func LoadFromEnv() (EnvConfig, error)

LoadFromEnv loads configuration from environment variables. It uses no prefix, matching the Python pydantic-settings behavior.

func LoadFromEnvWithPrefix

func LoadFromEnvWithPrefix(prefix string) (EnvConfig, error)

LoadFromEnvWithPrefix loads configuration with a custom prefix. For example, prefix "KODIT" would require KODIT_DATA_DIR instead of DATA_DIR.

func (EnvConfig) Normalize

func (e EnvConfig) Normalize() EnvConfig

Normalize returns a copy of the EnvConfig with legacy Python-format values converted to their Go equivalents. It logs warnings for each transformation so users know to update their .env files.

func (EnvConfig) ToAppConfig

func (e EnvConfig) ToAppConfig() AppConfig

ToAppConfig converts EnvConfig to AppConfig.

type LiteLLMCacheConfig

type LiteLLMCacheConfig struct {
	// contains filtered or unexported fields
}

LiteLLMCacheConfig configures LLM response caching.

func NewLiteLLMCacheConfig

func NewLiteLLMCacheConfig() LiteLLMCacheConfig

NewLiteLLMCacheConfig creates a new LiteLLMCacheConfig with defaults.

func (LiteLLMCacheConfig) Enabled

func (c LiteLLMCacheConfig) Enabled() bool

Enabled returns whether caching is enabled.

func (LiteLLMCacheConfig) WithEnabled

func (c LiteLLMCacheConfig) WithEnabled(enabled bool) LiteLLMCacheConfig

WithEnabled returns a new config with the specified enabled state.

type LiteLLMCacheEnv

type LiteLLMCacheEnv struct {
	// Enabled controls whether caching is enabled.
	// Env: LITELLM_CACHE_ENABLED (default: true)
	Enabled bool `envconfig:"ENABLED" default:"true"`
}

LiteLLMCacheEnv holds environment configuration for LLM caching.

func (LiteLLMCacheEnv) ToLiteLLMCacheConfig

func (l LiteLLMCacheEnv) ToLiteLLMCacheConfig() LiteLLMCacheConfig

ToLiteLLMCacheConfig converts LiteLLMCacheEnv to LiteLLMCacheConfig.

type LogFormat

type LogFormat string

LogFormat represents the log output format.

const (
	LogFormatPretty LogFormat = "pretty"
	LogFormatJSON   LogFormat = "json"
)

LogFormat values.

type PeriodicSyncConfig

type PeriodicSyncConfig struct {
	// contains filtered or unexported fields
}

PeriodicSyncConfig configures periodic repository syncing.

func NewPeriodicSyncConfig

func NewPeriodicSyncConfig() PeriodicSyncConfig

NewPeriodicSyncConfig creates a new PeriodicSyncConfig with defaults.

func (PeriodicSyncConfig) CheckInterval

func (p PeriodicSyncConfig) CheckInterval() time.Duration

CheckInterval returns how often to check for repositories due for sync.

func (PeriodicSyncConfig) Enabled

func (p PeriodicSyncConfig) Enabled() bool

Enabled returns whether periodic sync is enabled.

func (PeriodicSyncConfig) Interval

func (p PeriodicSyncConfig) Interval() time.Duration

Interval returns the sync interval as a duration.

func (PeriodicSyncConfig) RetryAttempts

func (p PeriodicSyncConfig) RetryAttempts() int

RetryAttempts returns the retry count.

func (PeriodicSyncConfig) WithCheckIntervalSeconds

func (p PeriodicSyncConfig) WithCheckIntervalSeconds(seconds float64) PeriodicSyncConfig

WithCheckIntervalSeconds returns a new config with the specified check interval.

func (PeriodicSyncConfig) WithEnabled

func (p PeriodicSyncConfig) WithEnabled(enabled bool) PeriodicSyncConfig

WithEnabled returns a new config with the specified enabled state.

func (PeriodicSyncConfig) WithIntervalSeconds

func (p PeriodicSyncConfig) WithIntervalSeconds(seconds float64) PeriodicSyncConfig

WithIntervalSeconds returns a new config with the specified interval.

func (PeriodicSyncConfig) WithRetryAttempts

func (p PeriodicSyncConfig) WithRetryAttempts(attempts int) PeriodicSyncConfig

WithRetryAttempts returns a new config with the specified retry count.

type PeriodicSyncEnv

type PeriodicSyncEnv struct {
	// Enabled controls whether periodic sync is enabled.
	// Env: PERIODIC_SYNC_ENABLED (default: true)
	Enabled bool `envconfig:"ENABLED" default:"true"`

	// IntervalSeconds is the sync interval in seconds.
	// Env: PERIODIC_SYNC_INTERVAL_SECONDS (default: 1800)
	IntervalSeconds float64 `envconfig:"INTERVAL_SECONDS" default:"1800"`

	// RetryAttempts is the number of retry attempts.
	// Env: PERIODIC_SYNC_RETRY_ATTEMPTS (default: 3)
	RetryAttempts int `envconfig:"RETRY_ATTEMPTS" default:"3"`
}

PeriodicSyncEnv holds environment configuration for periodic sync.

func (PeriodicSyncEnv) ToPeriodicSyncConfig

func (p PeriodicSyncEnv) ToPeriodicSyncConfig() PeriodicSyncConfig

ToPeriodicSyncConfig converts PeriodicSyncEnv to PeriodicSyncConfig.

type RemoteConfig

type RemoteConfig struct {
	// contains filtered or unexported fields
}

RemoteConfig configures remote server connection.

func NewRemoteConfig

func NewRemoteConfig() RemoteConfig

NewRemoteConfig creates a new RemoteConfig with defaults.

func NewRemoteConfigWithOptions

func NewRemoteConfigWithOptions(opts ...RemoteConfigOption) RemoteConfig

NewRemoteConfigWithOptions creates a RemoteConfig with options.

func (RemoteConfig) APIKey

func (r RemoteConfig) APIKey() string

APIKey returns the API key.

func (RemoteConfig) IsConfigured

func (r RemoteConfig) IsConfigured() bool

IsConfigured returns true if remote mode is configured.

func (RemoteConfig) MaxRetries

func (r RemoteConfig) MaxRetries() int

MaxRetries returns the maximum retry count.

func (RemoteConfig) ServerURL

func (r RemoteConfig) ServerURL() string

ServerURL returns the remote server URL.

func (RemoteConfig) Timeout

func (r RemoteConfig) Timeout() time.Duration

Timeout returns the request timeout.

func (RemoteConfig) VerifySSL

func (r RemoteConfig) VerifySSL() bool

VerifySSL returns whether SSL verification is enabled.

type RemoteConfigOption

type RemoteConfigOption func(*RemoteConfig)

RemoteConfigOption is a functional option for RemoteConfig.

func WithRemoteAPIKey

func WithRemoteAPIKey(key string) RemoteConfigOption

WithRemoteAPIKey sets the API key.

func WithRemoteMaxRetries

func WithRemoteMaxRetries(n int) RemoteConfigOption

WithRemoteMaxRetries sets the max retries.

func WithRemoteTimeout

func WithRemoteTimeout(d time.Duration) RemoteConfigOption

WithRemoteTimeout sets the timeout.

func WithServerURL

func WithServerURL(url string) RemoteConfigOption

WithServerURL sets the server URL.

func WithVerifySSL

func WithVerifySSL(verify bool) RemoteConfigOption

WithVerifySSL sets SSL verification.

type RemoteEnv

type RemoteEnv struct {
	// ServerURL is the remote server URL.
	// Env: REMOTE_SERVER_URL
	ServerURL string `envconfig:"SERVER_URL"`

	// APIKey is the API key for authentication.
	// Env: REMOTE_API_KEY
	APIKey string `envconfig:"API_KEY"`

	// Timeout is the request timeout in seconds.
	// Env: REMOTE_TIMEOUT (default: 30)
	Timeout float64 `envconfig:"TIMEOUT" default:"30"`

	// MaxRetries is the maximum retry attempts.
	// Env: REMOTE_MAX_RETRIES (default: 3)
	MaxRetries int `envconfig:"MAX_RETRIES" default:"3"`

	// VerifySSL controls SSL certificate verification.
	// Env: REMOTE_VERIFY_SSL (default: true)
	VerifySSL bool `envconfig:"VERIFY_SSL" default:"true"`
}

RemoteEnv holds environment configuration for remote server.

func (RemoteEnv) IsConfigured

func (r RemoteEnv) IsConfigured() bool

IsConfigured returns true if remote server URL is configured.

func (RemoteEnv) ToRemoteConfig

func (r RemoteEnv) ToRemoteConfig() RemoteConfig

ToRemoteConfig converts RemoteEnv to RemoteConfig.

type ReportingConfig

type ReportingConfig struct {
	// contains filtered or unexported fields
}

ReportingConfig configures progress reporting.

func NewReportingConfig

func NewReportingConfig() ReportingConfig

NewReportingConfig creates a new ReportingConfig with defaults.

func (ReportingConfig) LogTimeInterval

func (r ReportingConfig) LogTimeInterval() time.Duration

LogTimeInterval returns the time interval for logging progress.

func (ReportingConfig) WithLogTimeInterval

func (r ReportingConfig) WithLogTimeInterval(d time.Duration) ReportingConfig

WithLogTimeInterval returns a new config with the specified interval.

type ReportingEnv

type ReportingEnv struct {
	// LogTimeInterval is the logging interval in seconds.
	// Env: REPORTING_LOG_TIME_INTERVAL (default: 5)
	LogTimeInterval float64 `envconfig:"LOG_TIME_INTERVAL" default:"5"`
}

ReportingEnv holds environment configuration for reporting.

func (ReportingEnv) ToReportingConfig

func (r ReportingEnv) ToReportingConfig() ReportingConfig

ToReportingConfig converts ReportingEnv to ReportingConfig.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL