config

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2026 License: MIT Imports: 9 Imported by: 0

README

internal/config

Logic overview

The config package loads YAML configuration, applies defaults, parses flexible durations, and validates runtime constraints.

  • YAML decoding uses yaml.v3 with known-field enforcement.
  • Duration fields support Go duration syntax plus d (days) and w (weeks).
  • Defaults are applied for log level, metrics topology, store backend/mode, and export cache mode.
  • Validation enforces role-critical constraints (org uniqueness, fallback budgets, store mode requirements).

API reference

Types
  • Config: root application configuration.
  • ServerConfig: HTTP bind address and log level.
  • MetricsConfig: metrics scrape topology settings.
  • LeaderElectionConfig: lease/election timing and names.
  • GitHubConfig: API settings and organization blocks.
  • GitHubOrgConfig: per-org GitHub App installation and scrape settings.
  • RateLimitConfig: rate-limit policy controls.
  • RetryConfig: retry attempt/backoff controls.
  • LOCConfig: LOC source and fallback policy settings.
  • BackfillConfig: queue processing and dedup settings.
  • AMQPConfig: RabbitMQ endpoint/exchange/queue names.
  • StoreConfig: Redis backend and retention/cache settings.
  • HealthConfig: dependency probe settings.
  • TelemetryConfig: OpenTelemetry mode and sampling settings.
Functions
  • Load(reader io.Reader) (*Config, error): decodes YAML, applies defaults, validates, and returns config.
Methods
  • (*Config) Validate() error: validates semantic constraints and aggregates validation failures.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AMQPConfig

type AMQPConfig struct {
	URL      string `yaml:"url"`
	Exchange string `yaml:"exchange"`
	Queue    string `yaml:"queue"`
	DLQ      string `yaml:"dlq"`
}

AMQPConfig configures RabbitMQ/AMQP connectivity.

type BackfillConfig

type BackfillConfig struct {
	Enabled                    bool
	MaxMessageAge              time.Duration
	ConsumerCount              int
	RequeueDelays              []time.Duration
	CoalesceWindow             time.Duration
	DedupTTL                   time.Duration
	MaxEnqueuesPerOrgPerMinute int
}

BackfillConfig configures backfill queue behavior.

type Config

type Config struct {
	Server         ServerConfig
	Metrics        MetricsConfig
	LeaderElection LeaderElectionConfig
	GitHub         GitHubConfig
	RateLimit      RateLimitConfig
	Retry          RetryConfig
	LOC            LOCConfig
	Backfill       BackfillConfig
	AMQP           AMQPConfig
	Store          StoreConfig
	Health         HealthConfig
	Telemetry      TelemetryConfig
}

Config is the root application configuration.

func Load

func Load(reader io.Reader) (*Config, error)

Load reads configuration from YAML and validates the result.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates configuration values.

type GitHubConfig

type GitHubConfig struct {
	APIBaseURL                string
	RequestTimeout            time.Duration
	UnhealthyFailureThreshold int
	UnhealthyCooldown         time.Duration
	Orgs                      []GitHubOrgConfig
}

GitHubConfig configures GitHub API interactions.

type GitHubOrgConfig

type GitHubOrgConfig struct {
	Org               string `yaml:"org"`
	AppID             int64  `yaml:"app_id"`
	InstallationID    int64  `yaml:"installation_id"`
	PrivateKeyPath    string `yaml:"private_key_path"`
	ScrapeInterval    time.Duration
	RepoAllowlist     []string `yaml:"repo_allowlist"`
	PerOrgConcurrency int      `yaml:"per_org_concurrency"`
}

GitHubOrgConfig configures a single organization scrape target.

type HealthConfig

type HealthConfig struct {
	GitHubProbeInterval           time.Duration
	GitHubRecoverSuccessThreshold int
}

HealthConfig configures health probe behavior.

type LOCConfig

type LOCConfig struct {
	Source                                    string
	RefreshInterval                           time.Duration
	FallbackEnabled                           bool
	FallbackMaxCommitsPerRepoPerWeek          int
	FallbackMaxCommitDetailCallsPerOrgPerHour int
	LargeRepoZeroDetectionWindows             int
	LargeRepoCooldown                         time.Duration
}

LOCConfig configures lines-of-code metrics.

type LeaderElectionConfig

type LeaderElectionConfig struct {
	Enabled       bool
	Namespace     string
	LeaseName     string
	LeaseDuration time.Duration
	RenewDeadline time.Duration
	RetryPeriod   time.Duration
}

LeaderElectionConfig contains leader election settings.

type MetricsConfig

type MetricsConfig struct {
	Topology         string `yaml:"topology"`
	ScrapeServiceDNS string `yaml:"scrape_service_dns"`
}

MetricsConfig contains scrape topology settings.

type RateLimitConfig

type RateLimitConfig struct {
	MinRemainingThreshold int
	MinResetBuffer        time.Duration
	SecondaryLimitBackoff time.Duration
}

RateLimitConfig configures rate-limit controls.

type RetryConfig

type RetryConfig struct {
	MaxAttempts    int
	InitialBackoff time.Duration
	MaxBackoff     time.Duration
	Jitter         bool
}

RetryConfig configures retries.

type ServerConfig

type ServerConfig struct {
	ListenAddr string `yaml:"listen_addr"`
	LogLevel   string `yaml:"log_level"`
}

ServerConfig contains HTTP server settings.

type StoreConfig

type StoreConfig struct {
	Backend               string
	RedisMode             string
	RedisAddr             string
	RedisMasterSet        string
	RedisSentinelAddrs    []string
	RedisPassword         string
	RedisDB               int
	Retention             time.Duration
	MetricRefreshInterval time.Duration
	IndexShards           int
	ExportCacheMode       string
	MaxSeriesBudget       int
}

StoreConfig configures metric storage.

type TelemetryConfig

type TelemetryConfig struct {
	OTELEnabled          bool
	OTELExporterEndpoint string
	OTELTraceMode        string
	OTELTraceSampleRatio float64
}

TelemetryConfig configures OpenTelemetry behavior.

Jump to

Keyboard shortcuts

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