config

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvKeyPrefix    = "VEF"
	EnvNodeID       = EnvKeyPrefix + "_NODE_ID"       // XID node identifier
	EnvLogLevel     = EnvKeyPrefix + "_LOG_LEVEL"     // Log level (debug|info|warn|error)
	EnvConfigPath   = EnvKeyPrefix + "_CONFIG_PATH"   // Custom config file path
	EnvI18NLanguage = EnvKeyPrefix + "_I18N_LANGUAGE" // Override default language
)

Environment variable keys.

View Source
const (
	DefaultMaxUploadSize int64 = 1024 * 1024 * 1024 // 1 GiB

	DefaultClaimTTL         time.Duration = 24 * time.Hour
	DefaultMaxPendingClaims int           = 100

	DefaultSweepInterval  time.Duration = 5 * time.Minute
	DefaultSweepBatchSize int           = 200

	DefaultDeleteWorkerInterval time.Duration = 5 * time.Minute
	DefaultDeleteBatchSize      int           = 100
	DefaultDeleteConcurrency    int           = 8
	DefaultDeleteMaxAttempts    int           = 12
	DefaultDeleteLeaseWindow    time.Duration = 5 * time.Minute
)

Default upload-flow and worker tunables. Mirror the values documented in the upload API design; configuration overrides apply iff strictly positive (a zero or negative value re-selects the default).

Variables

View Source
var ErrInboxRetentionTooShort = errors.New(
	"event: inbox.retention is shorter than the outbox exponential-backoff horizon")

ErrInboxRetentionTooShort indicates the inbox retention window is smaller than the worst-case exponential-backoff horizon implied by the outbox max_retries. With such a configuration a duplicate delivery from the outbox could arrive after its inbox dedupe entry has already been pruned, producing double-execution.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Name      string `config:"name"`
	Port      uint16 `config:"port"`
	BodyLimit string `config:"body_limit"`
}

AppConfig defines core application settings.

type ApprovalConfig

type ApprovalConfig struct {
	// AutoMigrate runs the approval DDL migration on application start.
	AutoMigrate bool `config:"auto_migrate"`

	// TimeoutScanInterval is the polling cadence for the timeout scanner
	// that finds tasks past their deadline. Default: 1 minute.
	TimeoutScanInterval time.Duration `config:"timeout_scan_interval"`

	// PreWarningScanInterval is the polling cadence for the pre-warning
	// scanner that notifies before a task hits its deadline. Default: 5 minutes.
	PreWarningScanInterval time.Duration `config:"pre_warning_scan_interval"`

	// CleanupScanInterval is the cadence of the retention cleanup job
	// that prunes form snapshots, urge records, and CC records past
	// their retention window. Default: 24 hours.
	CleanupScanInterval time.Duration `config:"cleanup_scan_interval"`

	// DelegationMaxDepth caps how deep a delegation chain (A→B→C…) can
	// be resolved before short-circuiting. Default: 10.
	DelegationMaxDepth int `config:"delegation_max_depth"`

	// FormSnapshotRetention is the retention window for apv_form_snapshot
	// rows; older snapshots are deleted by the cleanup job. Default: 90 days.
	FormSnapshotRetention time.Duration `config:"form_snapshot_retention"`

	// UrgeRecordRetention is the retention window for apv_urge_record rows.
	// Default: 30 days.
	UrgeRecordRetention time.Duration `config:"urge_record_retention"`

	// CCRecordRetention is the retention window for apv_cc_record rows
	// (only records that have been read are pruned). Default: 90 days.
	CCRecordRetention time.Duration `config:"cc_record_retention"`
}

ApprovalConfig defines approval workflow engine settings.

Outbox-related fields previously lived here; they have moved to EventConfig.Transports.Outbox so the framework-wide outbox transport can serve any module, not just approval.

func (*ApprovalConfig) ApplyDefaults added in v0.24.0

func (c *ApprovalConfig) ApplyDefaults()

ApplyDefaults fills zero-valued fields with sensible defaults so callers don't have to mirror them in every TOML file.

type Config

type Config interface {
	// Unmarshal decodes configuration at the given key into target.
	Unmarshal(key string, target any) error
}

Config provides access to application configuration values.

type CorsConfig

type CorsConfig struct {
	Enabled      bool     `config:"enabled"`
	AllowOrigins []string `config:"allow_origins"`
}

CorsConfig defines CORS middleware settings.

type DBKind

type DBKind string

DBKind represents supported database kinds.

const (
	Oracle    DBKind = "oracle"
	SQLServer DBKind = "sqlserver"
	Postgres  DBKind = "postgres"
	MySQL     DBKind = "mysql"
	SQLite    DBKind = "sqlite"
)

Supported database kinds.

type DataSourceConfig

type DataSourceConfig struct {
	Kind           DBKind `config:"type"`
	Host           string `config:"host"`
	Port           uint16 `config:"port"`
	User           string `config:"user"`
	Password       string `config:"password"`
	Database       string `config:"database"`
	Schema         string `config:"schema"`
	Path           string `config:"path"`
	EnableSQLGuard bool   `config:"enable_sql_guard"`
}

DataSourceConfig defines database connection settings.

type EventConfig added in v0.24.0

type EventConfig struct {
	// DefaultTransport is the route fallback when no rule matches.
	DefaultTransport string `config:"default_transport"`
	// AsyncQueueSize is the capacity of the async fan-in queue used
	// by WithAsync publishes.
	AsyncQueueSize int `config:"async_queue_size"`
	// AsyncWorkers is the number of goroutines draining the async
	// fan-in queue.
	AsyncWorkers int `config:"async_workers"`
	// PublishTimeout caps an individual transport.Publish call.
	PublishTimeout time.Duration `config:"publish_timeout"`

	Transports EventTransportsConfig `config:"transports"`
	Middleware EventMiddlewareConfig `config:"middleware"`
	Inbox      EventInboxConfig      `config:"inbox"`
	// Routing is matched top-to-bottom; the first rule whose Pattern
	// matches via path.Match wins. fan-out is expressed by listing
	// multiple transports in Transports.
	Routing []EventRoutingRule `config:"routing"`
}

EventConfig governs the framework event bus: transports, routing, middleware, and the consume-side Inbox table.

func (*EventConfig) EffectiveAsyncQueueSize added in v0.24.0

func (c *EventConfig) EffectiveAsyncQueueSize() int

EffectiveAsyncQueueSize applies the default.

func (*EventConfig) EffectiveAsyncWorkers added in v0.24.0

func (c *EventConfig) EffectiveAsyncWorkers() int

EffectiveAsyncWorkers applies the default.

func (*EventConfig) EffectiveDefaultTransport added in v0.24.0

func (c *EventConfig) EffectiveDefaultTransport() string

EffectiveDefaultTransport applies the default fallback.

func (*EventConfig) EffectivePublishTimeout added in v0.24.0

func (c *EventConfig) EffectivePublishTimeout() time.Duration

EffectivePublishTimeout applies the default.

func (*EventConfig) Validate added in v0.24.0

func (c *EventConfig) Validate() error

Validate checks invariants that cross multiple subtrees of the EventConfig. Called once at fx Start. Currently enforced:

  • The inbox retention window must comfortably outlast the worst case outbox retry horizon (sum of 2^k seconds across max_retries attempts) so dedupe entries survive the longest delayed duplicate.

type EventInboxConfig added in v0.24.0

type EventInboxConfig struct {
	Retention       time.Duration `config:"retention"`
	ProcessingLease time.Duration `config:"processing_lease"`
	CleanupInterval time.Duration `config:"cleanup_interval"`
}

EventInboxConfig governs the inbox table retention, processing leases, and cleanup.

func (*EventInboxConfig) EffectiveCleanupInterval added in v0.24.0

func (c *EventInboxConfig) EffectiveCleanupInterval() time.Duration

EffectiveCleanupInterval applies the default of 1 hour.

func (*EventInboxConfig) EffectiveProcessingLease added in v0.24.0

func (c *EventInboxConfig) EffectiveProcessingLease() time.Duration

EffectiveProcessingLease applies the default of 10 minutes.

func (*EventInboxConfig) EffectiveRetention added in v0.24.0

func (c *EventInboxConfig) EffectiveRetention() time.Duration

EffectiveRetention applies the default of 7 days.

type EventMemoryTransportConfig added in v0.24.0

type EventMemoryTransportConfig struct {
	QueueSize      int           `config:"queue_size"`
	FullPolicy     string        `config:"full_policy"` // error | block | drop_oldest
	PublishTimeout time.Duration `config:"publish_timeout"`
}

EventMemoryTransportConfig configures the in-process transport.

type EventMiddlewareConfig added in v0.24.0

type EventMiddlewareConfig struct {
	Logging bool `config:"logging"`
	Tracing bool `config:"tracing"`
	// TracingStrict, when true, switches the Tracing middleware to
	// strict mode: incoming TraceIDs from cross-process transports are
	// treated as untrusted and parked under IncomingTraceIDFromContext;
	// a fresh ID is generated for log correlation. Default (false) is
	// W3C / OpenTelemetry-compatible propagation suitable for intra-
	// cluster pub/sub. Toggle this on at the edge between trust zones.
	TracingStrict bool `config:"tracing_strict"`
	Metrics       bool `config:"metrics"`
	Recover       bool `config:"recover"`
	// Inbox controls whether the consume-side idempotency middleware
	// is enabled. It only activates on transports whose Capabilities
	// declare AtLeastOnce regardless of this flag.
	Inbox bool `config:"inbox"`
}

EventMiddlewareConfig toggles the built-in consume/publish middlewares.

type EventOutboxTransportConfig added in v0.24.0

type EventOutboxTransportConfig struct {
	Enabled         bool          `config:"enabled"`
	RelayInterval   time.Duration `config:"relay_interval"`
	MaxRetries      int           `config:"max_retries"`
	BatchSize       int           `config:"batch_size"`
	LeaseMultiplier int           `config:"lease_multiplier"`
	MinLease        time.Duration `config:"min_lease"`
	SinkName        string        `config:"sink"`
	CleanupInterval time.Duration `config:"cleanup_interval"`
	CompletedTTL    time.Duration `config:"completed_ttl"`
}

EventOutboxTransportConfig configures the persistent outbox transport.

func (*EventOutboxTransportConfig) EffectiveCleanupInterval added in v0.24.0

func (c *EventOutboxTransportConfig) EffectiveCleanupInterval() time.Duration

EffectiveCleanupInterval applies the outbox cleanup default.

func (*EventOutboxTransportConfig) EffectiveCompletedTTL added in v0.24.0

func (c *EventOutboxTransportConfig) EffectiveCompletedTTL() time.Duration

EffectiveCompletedTTL applies the outbox completed-row TTL default.

type EventRedisStreamTransportConfig added in v0.24.0

type EventRedisStreamTransportConfig struct {
	Enabled        bool          `config:"enabled"`
	StreamPrefix   string        `config:"stream_prefix"`
	MaxLenApprox   int64         `config:"max_len_approx"`
	BlockTimeout   time.Duration `config:"block_timeout"`
	ClaimIdle      time.Duration `config:"claim_idle"`
	ClaimInterval  time.Duration `config:"claim_interval"`
	ClaimBatchSize int64         `config:"claim_batch_size"`
	ConsumerID     string        `config:"consumer_id"`
	StartID        string        `config:"start_id"`
}

EventRedisStreamTransportConfig configures the Redis Streams transport.

type EventRoutingRule added in v0.24.0

type EventRoutingRule struct {
	Pattern    string   `config:"pattern"`
	Transports []string `config:"transports"`
}

EventRoutingRule matches an event type to one or more transports. Pattern uses path.Match semantics ("*", "?", "[abc]"). The list of transports expresses fan-out — each frame is dispatched to every listed transport.

type EventTransportsConfig added in v0.24.0

type EventTransportsConfig struct {
	Memory      EventMemoryTransportConfig      `config:"memory"`
	Outbox      EventOutboxTransportConfig      `config:"outbox"`
	RedisStream EventRedisStreamTransportConfig `config:"redis_stream"`
}

EventTransportsConfig groups per-transport configuration blocks.

type FilesystemConfig

type FilesystemConfig struct {
	Root string `config:"root"`
}

FilesystemConfig defines filesystem storage settings.

type MCPConfig

type MCPConfig struct {
	Enabled     bool `config:"enabled"`
	RequireAuth bool `config:"require_auth"`
}

MCPConfig defines MCP server settings.

type MinIOConfig

type MinIOConfig struct {
	Endpoint  string `config:"endpoint"`
	AccessKey string `config:"access_key"`
	SecretKey string `config:"secret_key"`
	Bucket    string `config:"bucket"`
	Region    string `config:"region"`
	UseSSL    bool   `config:"use_ssl"`
}

MinIOConfig defines MinIO storage settings.

type MonitorConfig

type MonitorConfig struct {
	SampleInterval time.Duration `config:"sample_interval"` // Interval between samples (default: 10s)
	SampleDuration time.Duration `config:"sample_duration"` // Sampling window duration (default: 2s)
}

MonitorConfig defines monitoring service settings.

type RedisConfig

type RedisConfig struct {
	// Enabled gates the Redis client construction. When false (default) the
	// framework provides a nil *redis.Client into the fx graph and skips the
	// connection PING during start-up; downstream modules that ask for the
	// client via `optional:"true"` therefore stay dormant. Set this to true
	// only when the application actually depends on Redis (cache, redis_stream
	// transport, nonce store, etc.).
	Enabled  bool   `config:"enabled"`
	Host     string `config:"host"`
	Port     uint16 `config:"port"`
	User     string `config:"user"`
	Password string `config:"password"`
	Database uint8  `config:"database"` // Database number (0-15)
	Network  string `config:"network"`  // "tcp" or "unix" (default: "tcp")
}

RedisConfig defines Redis connection settings.

type SecurityConfig

type SecurityConfig struct {
	TokenExpires     time.Duration `config:"token_expires"`
	RefreshNotBefore time.Duration `config:"refresh_not_before"`
	LoginRateLimit   int           `config:"login_rate_limit"`
	RefreshRateLimit int           `config:"refresh_rate_limit"`
}

SecurityConfig defines security settings.

type StorageConfig

type StorageConfig struct {
	Provider    StorageProvider  `config:"provider"`
	AutoMigrate bool             `config:"auto_migrate"`
	MinIO       MinIOConfig      `config:"minio"`
	Filesystem  FilesystemConfig `config:"filesystem"`

	// MaxUploadSize is the hard upper bound (in bytes) on a single object
	// uploaded through the storage RPC, regardless of declared mode.
	// Default: 1 GiB.
	MaxUploadSize int64 `config:"max_upload_size"`

	// ClaimTTL is how long an upload claim stays valid before being swept.
	// Default: 24h.
	ClaimTTL time.Duration `config:"claim_ttl"`

	// MaxPendingClaims caps the number of in-flight (status='pending')
	// upload claims a single principal may hold simultaneously. Prevents
	// a single user from exhausting backend resources by opening
	// thousands of multipart sessions. Default: 100.
	MaxPendingClaims int `config:"max_pending_claims"`

	// AllowPublicUploads controls whether clients may set public=true on
	// init_upload. When false (default), all uploads land under priv/
	// regardless of the client's request. Set to true only when the
	// business explicitly needs user-initiated public uploads.
	AllowPublicUploads bool `config:"allow_public_uploads"`

	// SweepInterval is how often the claim sweeper polls for expired
	// upload claims. Default: 5m.
	SweepInterval time.Duration `config:"sweep_interval"`
	// SweepBatchSize bounds how many expired claims one sweep tick processes.
	// Default: 200.
	SweepBatchSize int `config:"sweep_batch_size"`

	// DeleteWorkerInterval is how often the delete worker polls for due
	// pending-delete rows. Default: 5m.
	DeleteWorkerInterval time.Duration `config:"delete_worker_interval"`
	// DeleteBatchSize bounds how many rows the delete worker leases per tick.
	// Default: 100.
	DeleteBatchSize int `config:"delete_batch_size"`
	// DeleteConcurrency caps the number of in-flight object deletions
	// per worker tick. Default: 8.
	DeleteConcurrency int `config:"delete_concurrency"`
	// DeleteMaxAttempts is the retry budget after which a pending-delete
	// row is parked as dead-letter. Default: 12.
	DeleteMaxAttempts int `config:"delete_max_attempts"`
	// DeleteLeaseWindow is the visibility timeout applied when leasing
	// rows. Should comfortably exceed expected per-item processing time.
	// Default: 5m.
	DeleteLeaseWindow time.Duration `config:"delete_lease_window"`
}

StorageConfig defines storage provider settings.

Upload-flow and worker tunables have working defaults applied at read time when their zero value is loaded; callers should not assume the parsed config carries non-zero values. Use the Effective* accessors instead of reading struct fields directly.

func (*StorageConfig) EffectiveClaimTTL added in v0.23.0

func (c *StorageConfig) EffectiveClaimTTL() time.Duration

EffectiveClaimTTL returns ClaimTTL or its default.

func (*StorageConfig) EffectiveDeleteBatchSize added in v0.23.0

func (c *StorageConfig) EffectiveDeleteBatchSize() int

EffectiveDeleteBatchSize returns DeleteBatchSize or its default.

func (*StorageConfig) EffectiveDeleteConcurrency added in v0.23.0

func (c *StorageConfig) EffectiveDeleteConcurrency() int

EffectiveDeleteConcurrency returns DeleteConcurrency or its default.

func (*StorageConfig) EffectiveDeleteLeaseWindow added in v0.23.0

func (c *StorageConfig) EffectiveDeleteLeaseWindow() time.Duration

EffectiveDeleteLeaseWindow returns DeleteLeaseWindow or its default.

func (*StorageConfig) EffectiveDeleteMaxAttempts added in v0.23.0

func (c *StorageConfig) EffectiveDeleteMaxAttempts() int

EffectiveDeleteMaxAttempts returns DeleteMaxAttempts or its default.

func (*StorageConfig) EffectiveDeleteWorkerInterval added in v0.23.0

func (c *StorageConfig) EffectiveDeleteWorkerInterval() time.Duration

EffectiveDeleteWorkerInterval returns DeleteWorkerInterval or its default.

func (*StorageConfig) EffectiveMaxPendingClaims added in v0.23.0

func (c *StorageConfig) EffectiveMaxPendingClaims() int

EffectiveMaxPendingClaims returns MaxPendingClaims or its default.

func (*StorageConfig) EffectiveMaxUploadSize added in v0.23.0

func (c *StorageConfig) EffectiveMaxUploadSize() int64

EffectiveMaxUploadSize returns MaxUploadSize or its default.

func (*StorageConfig) EffectiveSweepBatchSize added in v0.23.0

func (c *StorageConfig) EffectiveSweepBatchSize() int

EffectiveSweepBatchSize returns SweepBatchSize or its default.

func (*StorageConfig) EffectiveSweepInterval added in v0.23.0

func (c *StorageConfig) EffectiveSweepInterval() time.Duration

EffectiveSweepInterval returns SweepInterval or its default.

type StorageProvider

type StorageProvider string

StorageProvider represents supported storage backend types.

const (
	StorageMinIO      StorageProvider = "minio"
	StorageMemory     StorageProvider = "memory"
	StorageFilesystem StorageProvider = "filesystem"
)

Supported storage providers.

Jump to

Keyboard shortcuts

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