globalconfig

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package globalconfig serves the runtime global config as a lock-free atomic snapshot loaded from the instance_config singleton, shared by the service and server layers. Load at boot; refresh after every write (write-through).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Accessor

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

Accessor holds the current global-config snapshot behind an atomic pointer.

func New

func New(loader Loader) *Accessor

New returns an accessor seeded with a zero snapshot; call Load before reads.

func (*Accessor) AdminEmails

func (a *Accessor) AdminEmails() string

func (*Accessor) CandidatePool

func (a *Accessor) CandidatePool() int

func (*Accessor) CleanupEnabled

func (a *Accessor) CleanupEnabled() bool

func (*Accessor) CleanupIntervalHours

func (a *Accessor) CleanupIntervalHours() int

func (*Accessor) CleanupScanDefault

func (a *Accessor) CleanupScanDefault() bool

func (*Accessor) DuplicateGuardDefault

func (a *Accessor) DuplicateGuardDefault() bool

func (*Accessor) DuplicateThreshold

func (a *Accessor) DuplicateThreshold() float64

func (*Accessor) HistoryEnabled

func (a *Accessor) HistoryEnabled() bool

func (*Accessor) HistoryRetentionDays

func (a *Accessor) HistoryRetentionDays() int

func (*Accessor) Load

func (a *Accessor) Load(ctx context.Context) error

Load reads instance_config and swaps in a fresh snapshot.

func (*Accessor) LogLevel

func (a *Accessor) LogLevel() string

func (*Accessor) MMRLambda

func (a *Accessor) MMRLambda() float64

Typed getters — each reads the live snapshot lock-free.

func (*Accessor) MaxRequestBytes

func (a *Accessor) MaxRequestBytes() int64

func (*Accessor) RateLimitBurst

func (a *Accessor) RateLimitBurst() int

func (*Accessor) RateLimitRPS

func (a *Accessor) RateLimitRPS() float64

func (*Accessor) Refresh

func (a *Accessor) Refresh(ctx context.Context) error

Refresh reloads the snapshot after a write (write-through invalidation).

func (*Accessor) SelfServicePolicy

func (a *Accessor) SelfServicePolicy() string

func (*Accessor) SignupDomains

func (a *Accessor) SignupDomains() string

func (*Accessor) Snapshot

func (a *Accessor) Snapshot() *Snapshot

Snapshot returns the current snapshot; never nil after New.

func (*Accessor) SnippetChars

func (a *Accessor) SnippetChars() int

func (*Accessor) StalenessDefault

func (a *Accessor) StalenessDefault() string

func (*Accessor) StalenessPenalty

func (a *Accessor) StalenessPenalty() float64

func (*Accessor) TrustedProxyDepth

func (a *Accessor) TrustedProxyDepth() int

func (*Accessor) WebhookURL

func (a *Accessor) WebhookURL() string

type Loader

type Loader interface {
	Get(ctx context.Context) (*models.InstanceConfig, error)
}

Loader fetches the singleton instance_config row. *repository.InstanceConfigRepository satisfies it.

type Snapshot

type Snapshot struct {
	MMRLambda             float64
	StalenessPenalty      float64
	CandidatePool         int
	SnippetChars          int
	HistoryRetentionDays  int
	HistoryEnabled        bool
	StalenessDefault      string
	DuplicateGuardDefault bool
	CleanupScanDefault    bool
	DuplicateThreshold    float64
	SelfServicePolicy     string
	SignupDomains         string
	AdminEmails           string
	CleanupEnabled        bool
	CleanupIntervalHours  int
	RateLimitRPS          float64
	RateLimitBurst        int
	TrustedProxyDepth     int
	MaxRequestBytes       int64
	LogLevel              string
	WebhookURL            string
}

Snapshot is an immutable typed view of the globals, swapped atomically on refresh.

Jump to

Keyboard shortcuts

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