Documentation
¶
Overview ¶
Package config defines the sqi-server runtime configuration and provides layered loading from built-in defaults, a YAML/JSON file, SQI_* environment variables, and CLI flag overrides — in that override order.
Typical usage in the serve subcommand:
cfg, err := config.Load(flagConfigFile, config.FlagOverrides{
LogLevel: flagLogLevel,
LogFormat: flagLogFormat,
HTTPAddr: flagHTTPAddr,
})
if err != nil {
return err
}
if errs := config.Validate(cfg); len(errs) > 0 {
for _, e := range errs {
fmt.Fprintf(os.Stderr, "config error: %s: %s\n", e.Field, e.Message)
}
return fmt.Errorf("%d configuration error(s)", len(errs))
}
Index ¶
- Constants
- func CheckFileKeys(data []byte) error
- func ExpiringSoon(certFile string) (time.Time, bool)
- func LoadWithSources(filePath string, flags FlagOverrides) (Config, Sources, error)
- func SQLitePathIsURI(path string) bool
- func ValidCapacityName(name string) bool
- type AuthConfig
- type BootstrapConfig
- type CapacityConfig
- type CapacityProviderConfig
- type Config
- type DiagnosticsConfig
- type DiscoveryConfig
- type FlagOverrides
- type HAConfig
- type HTTPConfig
- type LDAPConfig
- type LogConfig
- type NATSAuthConfig
- type NATSCalloutConfig
- type NATSClientTLSConfig
- type NATSConfig
- type NATSEmbeddedConfig
- type NATSExternalConfig
- type NATSTLSConfig
- type NamedPath
- type OIDCConfig
- type OpenJDConfig
- type PostgresStoreConfig
- type PresetLibraryConfig
- type RateLimitConfig
- type RoleMappingConfig
- type SchedulerConfig
- type SessionConfig
- type Sources
- type StoreConfig
- type TLSConfig
- type ValidationError
- type WakeOnLANConfig
Constants ¶
const ( // NATSModeEmbedded runs the broker inside sqi-server (the default). NATSModeEmbedded = "embedded" // NATSModeExternal connects sqi-server to a broker the operator runs. NATSModeExternal = "external" )
The NATS broker modes.
const ( // MinNATSAuthJoinTokenTTL is the floor: below a minute an operator // cannot realistically get the token onto a machine and boot it. MinNATSAuthJoinTokenTTL = 1 * time.Minute // MaxNATSAuthJoinTokenTTL is the ceiling. A join token mints a worker // credential, so it is a bootstrap secret whose whole value is a short // blast radius; a token valid for weeks is a standing credential wearing // a different name. MaxNATSAuthJoinTokenTTL = 24 * time.Hour // MinNATSAuthUserTTL is the shortest worker user JWT lifetime. MinNATSAuthUserTTL = 1 * time.Minute // MaxNATSAuthUserTTL is the longest worker user JWT lifetime. MaxNATSAuthUserTTL = 24 * time.Hour )
const ( StoreDriverSQLite = "sqlite" StoreDriverPostgres = "postgres" )
The store drivers.
const ( // DefaultHALeaseTTL is the leader lease lifetime when ha.lease_ttl is unset. DefaultHALeaseTTL = 15 * time.Second // MinHALeaseTTL is the floor: the renew period is a third of the TTL, so // below this a single slow database round trip would cost the lease. MinHALeaseTTL = 6 * time.Second // MaxHALeaseTTL is the ceiling: a crashed leader stays leader for the // whole TTL, so a longer one only lengthens every failover. MaxHALeaseTTL = 60 * time.Second )
const ( // DefaultCapacityProviderTimeout is a provider invocation's time limit // when capacity.providers.<name>.timeout is unset. DefaultCapacityProviderTimeout = 2 * time.Minute // MinCapacityProviderTimeout is the floor: a shorter limit kills a // provider that is merely starting. MinCapacityProviderTimeout = 5 * time.Second // MaxCapacityProviderTimeout is the ceiling: a longer limit lets a hung // program hold a group's capacity decision for half an hour. MaxCapacityProviderTimeout = 30 * time.Minute // DefaultWakeOnLANPort is the discard port, the conventional magic-packet // target. DefaultWakeOnLANPort = 9 )
const ( DefaultOpenJDExprOperationLimit int64 = 10_000 MinOpenJDExprOperationLimit int64 = 1_000 MaxOpenJDExprOperationLimit int64 = 100_000 DefaultOpenJDExprMemoryLimit int64 = 1_000_000 MinOpenJDExprMemoryLimit int64 = 4_096 MaxOpenJDExprMemoryLimit int64 = 10_000_000 DefaultOpenJDExprTemplatePositions int64 = 10_000 MinOpenJDExprTemplatePositions int64 = 256 MaxOpenJDExprTemplatePositions int64 = 100_000 DefaultOpenJDExprTemplateRetainedBytes int64 = 10_000_000 MinOpenJDExprTemplateRetainedBytes int64 = 65_536 MaxOpenJDExprTemplateRetainedBytes int64 = 100_000_000 )
The defaults and the operator-configurable range for OpenJDConfig's four EXPR expression limits.
These duplicate internal/openjd's DefaultExprLimits and Min/MaxExpr* constants because internal/config must not import internal/openjd (that would be a cross-import between two same-level internal packages, and internal/openjd pulls in internal/store). TestExprLimits_ConfigMatchesOpenJD in internal/server, which may import both, fails if the two sides differ.
The rationale for each number (which bounds are catastrophe bounds with a ceiling no operator may raise past, which is a policy bound, and what each floor is set against) is on internal/openjd's ExprLimits and its Min/Max constants, next to the code the numbers govern.
const ( // DefaultOpenJDExprSubmissionDeadline is far below the worst case of more // than 15 minutes. The largest legitimate template accepted at the // defaults spends about 0.83 s in the expression checker, roughly 6x // headroom; raising the four EXPR limits without raising this deadline // can turn legitimate submissions into 503s. DefaultOpenJDExprSubmissionDeadline = 5 * time.Second // MinOpenJDExprSubmissionDeadline is the floor because below a second a // legitimate large template (a body near the 4 MiB request cap, on a busy // or slow host) could fail, and a backstop that rejects valid work is // worse than the exposure it guards. Below it the setting stops being a // backstop and becomes a load-dependent admission policy. MinOpenJDExprSubmissionDeadline = time.Second // MaxOpenJDExprSubmissionDeadline is the ceiling because the key exists // to bound the worst case, and a ceiling near it would bound nothing. It // is set against what a submission should ever need, not against the // worst case, whose true size is not known. MaxOpenJDExprSubmissionDeadline = 60 * time.Second )
The default and the operator-configurable range for OpenJDConfig.ExprSubmissionDeadline, the wall-clock backstop for EXPR evaluation.
Unlike the four above, these are not duplicated from internal/openjd: the deadline is a per-request instant computed from this duration, so internal/openjd holds no constant to keep in step with.
Variables ¶
This section is empty.
Functions ¶
func CheckFileKeys ¶ added in v0.4.0
CheckFileKeys reports every key in a config file's data that sqi-server would not accept: one it does not know, or one holding a value of the wrong shape (a section where a value belongs, or the reverse). Each message names the key by its dotted path. It decodes the file as the loader does and merges nothing, so it does not read the environment or validate values.
func ExpiringSoon ¶ added in v0.4.0
ExpiringSoon reports whether the leaf certificate in certFile expires within 30 days, returning its NotAfter.
It inspects the first CERTIFICATE block, which the docs require to be the leaf; a chain written the other way round would make it report the CA's expiry. It is advisory: startup warns, it does not refuse. Errors are ignored because Validate has already rejected anything unloadable.
It takes only the certificate: the private key has no bearing on expiry, and asking for it would imply otherwise.
func LoadWithSources ¶ added in v0.4.0
func LoadWithSources(filePath string, flags FlagOverrides) (Config, Sources, error)
LoadWithSources is Load, additionally reporting which of a subset of settings (see Sources) were explicitly decided by the config file or environment layer.
func SQLitePathIsURI ¶ added in v0.4.0
SQLitePathIsURI reports whether path is a SQLite "file:" URI. A SQLite path is a file path: backup, restore, store copy and the server's lock file all read it as one, so a URI is refused wherever the path is given. It matches internal/store/sqlite's isURI, which config cannot import without pulling in the SQLite driver.
func ValidCapacityName ¶ added in v0.4.0
ValidCapacityName reports whether name is a valid capacity group or provider name: 1-63 characters, letters, digits, '.', '_' or '-', starting with a letter or digit.
Types ¶
type AuthConfig ¶ added in v0.3.0
type AuthConfig struct {
// Enabled turns on the authentication gate. Default false — the server is
// open on a trusted local network.
// Env: SQI_AUTH_ENABLED
Enabled bool `yaml:"enabled"`
// ValidateJobOwner rejects a submission whose Owner names no known user.
// Default true — it keeps Job.Owner a trustworthy key for owner-scoped
// visibility: the user role's job listings are filtered by owner, so a
// typo'd owner yields a job invisible to the person who owns it and
// missed by an admin filtering on them. Disable it when owners come from
// a directory that has no local records for them.
// Env: SQI_AUTH_VALIDATE_JOB_OWNER
ValidateJobOwner bool `yaml:"validate_job_owner"`
// Session controls server-side session cookie behavior.
Session SessionConfig `yaml:"session"`
// Bootstrap seeds the first admin account when auth is enabled and the
// users table is empty.
Bootstrap BootstrapConfig `yaml:"bootstrap"`
// LDAP configures directory authentication. Disabled by default; when
// enabled it requires Auth.Enabled — LDAP without the auth gate would
// authenticate nobody.
LDAP LDAPConfig `yaml:"ldap"`
// OIDC configures OAuth2/OIDC single sign-on. Disabled by default; when
// enabled it requires Auth.Enabled — SSO without the auth gate would
// authenticate nobody.
OIDC OIDCConfig `yaml:"oidc"`
}
AuthConfig controls the opt-in authentication gate.
type BootstrapConfig ¶ added in v0.3.0
type BootstrapConfig struct {
// Username for the seeded first admin. Env: SQI_AUTH_BOOTSTRAP_USERNAME
Username string `yaml:"username"`
// Password for the seeded first admin. Redacted by [BootstrapConfig.MarshalYAML]
// whenever the config is re-marshaled (e.g. `sqi-server config print`), so it
// never appears in that output. Env: SQI_AUTH_BOOTSTRAP_PASSWORD
Password string `yaml:"password"`
}
BootstrapConfig seeds the first admin account when auth is enabled and no users exist yet. Empty is valid: the server warns and boots without creating an admin rather than failing closed.
func (BootstrapConfig) MarshalYAML ¶ added in v0.3.0
func (b BootstrapConfig) MarshalYAML() (any, error)
MarshalYAML redacts Password so it never appears in YAML output (e.g. `sqi-server config print`, logs of a marshaled config). It does not affect unmarshaling: a config file's real `password:` value loads as written. A redacted dump does not round-trip.
type CapacityConfig ¶ added in v0.4.0
type CapacityConfig struct {
// Providers are the external provider programs, by name. A capacity group
// selects one with `provider: script:<name>`.
Providers map[string]CapacityProviderConfig `yaml:"providers"`
// WakeOnLAN configures the built-in wake-on-LAN provider.
WakeOnLAN WakeOnLANConfig `yaml:"wake_on_lan"`
}
CapacityConfig configures how capacity groups reach machines: the external provider programs they may name (`provider: script:<name>`) and the wake-on-LAN sender.
There is no environment overlay for capacity.*: a provider is a program plus the secrets it needs, and a list of commands does not fit one variable, so providers are defined in the config file only. Group rows themselves live in the store and are managed through the API.
type CapacityProviderConfig ¶ added in v0.4.0
type CapacityProviderConfig struct {
// Command is the program and its arguments. Command[0] must be an
// absolute path: no PATH lookup decides which program the server runs.
Command []string `yaml:"command"`
// Env is added to the program's environment. Every value is redacted by
// [CapacityProviderConfig.MarshalYAML] (`config print`).
Env map[string]string `yaml:"env"`
// Timeout bounds one invocation. 5s to 30m, default 2m.
Timeout time.Duration `yaml:"timeout"`
}
CapacityProviderConfig is one external provider program.
func (CapacityProviderConfig) MarshalYAML ¶ added in v0.4.0
func (p CapacityProviderConfig) MarshalYAML() (any, error)
MarshalYAML redacts every Env value so a provider's credentials never appear in YAML output (e.g. `sqi-server config print`); the names stay visible. It does not affect unmarshaling or the loaded value. A redacted dump does not round-trip.
type Config ¶
type Config struct {
HTTP HTTPConfig `yaml:"http"`
NATS NATSConfig `yaml:"nats"`
Store StoreConfig `yaml:"store"`
Log LogConfig `yaml:"log"`
Scheduler SchedulerConfig `yaml:"scheduler"`
Discovery DiscoveryConfig `yaml:"discovery"`
OpenJD OpenJDConfig `yaml:"openjd"`
Diagnostics DiagnosticsConfig `yaml:"diagnostics"`
PresetLibrary PresetLibraryConfig `yaml:"preset_library"`
Auth AuthConfig `yaml:"auth"`
HA HAConfig `yaml:"ha"`
Capacity CapacityConfig `yaml:"capacity"`
}
Config is the complete runtime configuration for sqi-server. Zero values are not valid; use DefaultConfig or Load to obtain a populated instance.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns a Config with defaults suitable for local development. Production deployments should override fields via a config file or SQI_* environment variables.
func Load ¶
func Load(filePath string, flags FlagOverrides) (Config, error)
Load builds a Config by applying four layers in increasing precedence:
- Built-in defaults (DefaultConfig)
- YAML/JSON file at filePath, or the first file found in the default search path when filePath is empty
- SQI_* environment variables
- CLI flag overrides via flags
A missing config file is not an error unless filePath was set explicitly.
func (Config) NamedPaths ¶ added in v0.4.0
NamedPaths returns every file and directory the configuration names, as written (a relative path is relative to the server's working directory), skipping empty keys. A capacity provider's program counts when it contains a path separator; a bare name is found on PATH. On Windows, `service install` refuses a service whose named paths an unprivileged user could change: each one decides whom the server trusts or what it runs.
type DiagnosticsConfig ¶
type DiagnosticsConfig struct {
// BufferSize is the maximum diagnostic records retained per component
// (server + each worker). 0 disables diagnostics entirely: no ring buffer,
// no worker.diag subscription, and the REST endpoint returns 503. A positive
// value is the per-component capacity. Default: 1000. Set to 0 to avoid
// spending memory on something accessed out-of-band
// (journald/Docker/Loki/etc.). Must not be negative.
// Env: SQI_DIAGNOSTICS_BUFFER_SIZE
BufferSize int `yaml:"buffer_size"`
}
DiagnosticsConfig controls the in-memory diagnostic-log ring buffer surfaced in the web UI.
type DiscoveryConfig ¶
type DiscoveryConfig struct {
// Enabled controls whether sqi-server broadcasts a _sqi._tcp mDNS record
// on the local network. Disable in environments that forbid multicast.
// Env: SQI_DISCOVERY_ENABLED
Enabled bool `yaml:"enabled"`
// InstanceName is the mDNS service instance name advertised on the
// network. Defaults to "sqi-server".
// Env: SQI_DISCOVERY_INSTANCE_NAME
InstanceName string `yaml:"instance_name"`
}
DiscoveryConfig controls mDNS service advertisement.
type FlagOverrides ¶
type FlagOverrides struct {
// LogLevel overrides Log.Level when non-empty. Bound to --log-level.
LogLevel string
// LogFormat overrides Log.Format when non-empty. Bound to --log-format.
LogFormat string
// HTTPAddr overrides HTTP.Addr when non-empty. Bound to --http-addr.
HTTPAddr string
// HTTPCORSOrigins overrides HTTP.CORSOrigins when non-empty. Bound to
// --http-cors-origins.
HTTPCORSOrigins []string
// EnforceLimits overrides OpenJD.EnforceLimits when non-nil. Bound to
// --openjd-enforce-limits. A pointer (not a bool) so an unset flag leaves the
// lower layers intact while an explicit --openjd-enforce-limits=false can turn
// the (default-true) gate off.
EnforceLimits *bool
// AuthEnabled overrides Auth.Enabled when non-nil. Bound to --auth-enabled.
// A pointer so an unset flag leaves the lower layers intact.
AuthEnabled *bool
// ValidateJobOwner overrides Auth.ValidateJobOwner when non-nil. Bound to
// --auth-validate-job-owner. A pointer so an unset flag leaves the lower
// layers intact.
ValidateJobOwner *bool
}
FlagOverrides carries values from CLI flags that take highest precedence during config loading. Only non-empty / non-zero values override the lower layers, so callers can pass flag values that were not set without clobbering config-file or environment values.
type HAConfig ¶ added in v0.4.0
type HAConfig struct {
// Enabled lets this server join an HA group. It requires store.driver:
// postgres and nats.mode: external. Disabled by default; with it off the
// server behaves exactly as a single-server farm.
// Env: SQI_HA_ENABLED
Enabled bool `yaml:"enabled"`
// LeaseTTL is how long the leader's lease lasts without renewal, and so
// how long a failover waits after a crash. The renew period and the
// self-fence margin are derived from it. Range 6s to 60s.
// Env: SQI_HA_LEASE_TTL
LeaseTTL time.Duration `yaml:"lease_ttl"`
// InstanceName identifies this server in logs, /readyz and the servers
// list. Defaults to the host name.
// Env: SQI_HA_INSTANCE_NAME
InstanceName string `yaml:"instance_name"`
}
HAConfig controls high availability: several sqi-server processes sharing one PostgreSQL database and one external NATS account, with a single leader. Nothing under it is read or validated while Enabled is false.
type HTTPConfig ¶
type HTTPConfig struct {
// Addr is the TCP address the HTTP server listens on.
// Env: SQI_HTTP_ADDR
Addr string `yaml:"addr"`
// EnablePprof exposes the Go runtime profiling endpoints at /debug/pprof/
// when true. Profiling data is sensitive; never enable this on a server
// accessible to untrusted networks. Disabled by default.
// Env: SQI_HTTP_ENABLE_PPROF
EnablePprof bool `yaml:"enable_pprof"`
// RateLimit configures the per-IP API rate limit.
RateLimit RateLimitConfig `yaml:"rate_limit"`
// CORSOrigins is the list of browser origins the CORS middleware allows.
// Empty means "*" (the router's default). With auth enabled a wildcard is
// dropped at startup — credentials cannot be combined with "*" — so a
// separately-hosted UI must name its origin explicitly here.
// Env: SQI_HTTP_CORS_ORIGINS (comma-separated)
CORSOrigins []string `yaml:"cors_origins"`
// TLS terminates HTTPS in-process on this listener. Off by default.
TLS TLSConfig `yaml:"tls"`
}
HTTPConfig controls the REST and WebSocket listener.
type LDAPConfig ¶ added in v0.3.0
type LDAPConfig struct {
// Enabled turns on directory authentication.
// Env: SQI_AUTH_LDAP_ENABLED
Enabled bool `yaml:"enabled"`
// URL is the directory endpoint: ldap://host:389 or ldaps://host:636.
// Env: SQI_AUTH_LDAP_URL
URL string `yaml:"url"`
// StartTLS upgrades a plain ldap:// connection to TLS. Invalid with
// ldaps://, which is already TLS.
// Env: SQI_AUTH_LDAP_START_TLS
StartTLS bool `yaml:"start_tls"`
// TLSSkipVerify disables certificate verification. Logged as a warning at
// boot; never silently accepted.
// Env: SQI_AUTH_LDAP_TLS_SKIP_VERIFY
TLSSkipVerify bool `yaml:"tls_skip_verify"`
// CAFile is a PEM bundle used to verify the directory's certificate.
// Env: SQI_AUTH_LDAP_CA_FILE
CAFile string `yaml:"ca_file"`
// Timeout bounds a single dial/bind/search cycle.
// Env: SQI_AUTH_LDAP_TIMEOUT
Timeout time.Duration `yaml:"timeout"`
// BindDN is the service account used to search for users (search mode).
// Env: SQI_AUTH_LDAP_BIND_DN
BindDN string `yaml:"bind_dn"`
// BindPassword is the service account's password. Never logged: redacted
// by [LDAPConfig.MarshalYAML] whenever the config is re-marshaled (e.g.
// `sqi-server config print`).
// Env: SQI_AUTH_LDAP_BIND_PASSWORD
BindPassword string `yaml:"bind_password"`
// BaseDN is the subtree searched for user entries (search mode).
// Env: SQI_AUTH_LDAP_BASE_DN
BaseDN string `yaml:"base_dn"`
// UserFilter is the search filter; %s is replaced with the escaped
// username. Env: SQI_AUTH_LDAP_USER_FILTER
UserFilter string `yaml:"user_filter"`
// NestedGroups expands nested group membership via the AD matching-rule
// OID. Search mode only — template mode reads memberOf, which is flat.
// Env: SQI_AUTH_LDAP_NESTED_GROUPS
NestedGroups bool `yaml:"nested_groups"`
// UserDNTemplate builds the user's DN directly; %s is the escaped
// username. Selects template mode. Env: SQI_AUTH_LDAP_USER_DN_TEMPLATE
UserDNTemplate string `yaml:"user_dn_template"`
// UsernameAttr is the attribute holding the login name.
// Env: SQI_AUTH_LDAP_USERNAME_ATTR
UsernameAttr string `yaml:"username_attr"`
// DisplayNameAttr is the attribute holding the human-facing name. Read
// only at JIT-create; never overwritten afterwards.
// Env: SQI_AUTH_LDAP_DISPLAY_NAME_ATTR
DisplayNameAttr string `yaml:"display_name_attr"`
// UniqueIDAttr names the attribute holding the entry's stable,
// non-reusable identifier: "objectGUID" on Active Directory, "entryUUID"
// on OpenLDAP and other RFC 4530 servers.
//
// Required when LDAP is enabled, with no default: no single value is
// correct on both server families, and probing for one would silently
// guess wrong on a server exposing both. Accounts are matched on this,
// never on username — a name lets a recycled identity inherit an account.
// Env: SQI_AUTH_LDAP_UNIQUE_ID_ATTR
UniqueIDAttr string `yaml:"unique_id_attr"`
// RoleSource decides who owns an LDAP user's role:
// - "directory" (default): recomputed from groups on every login, and
// the users API rejects role edits on LDAP accounts.
// - "local": groups seed the role at JIT-create only; admins own it
// afterwards and the API allows edits.
// Both halves are driven by this one value — never configure them apart,
// or a role edit will appear to succeed and silently revert at next login.
// Env: SQI_AUTH_LDAP_ROLE_SOURCE
RoleSource string `yaml:"role_source"`
// RoleMap maps group DNs to roles, first match wins. Order is
// significant: it is how an operator expresses precedence.
RoleMap []RoleMappingConfig `yaml:"role_map"`
// DefaultRole applies when no group matches. Empty means reject the
// login, so a deployment can require group membership to sign in at all.
// Env: SQI_AUTH_LDAP_DEFAULT_ROLE
DefaultRole string `yaml:"default_role"`
}
LDAPConfig configures LDAP/Active Directory authentication.
LDAP is a login-time credential verifier, not a per-request authenticator: an account whose users.auth_source is "ldap" has its password checked against the directory by POST /auth/login, which then mints the same server-side session every local account gets.
Two bind modes are mutually exclusive. Setting UserDNTemplate selects template mode (bind directly as the user, read their own memberOf); leaving it empty and setting BindDN/BaseDN selects search-then-bind.
func (LDAPConfig) MarshalYAML ¶ added in v0.3.0
func (l LDAPConfig) MarshalYAML() (any, error)
MarshalYAML redacts BindPassword so it never appears in YAML output (e.g. `sqi-server config print`, logs of a marshaled config). It does not affect unmarshaling: a config file's real `bind_password:` value loads as written. A redacted dump does not round-trip.
type LogConfig ¶
type LogConfig struct {
// Level is the minimum log level to emit.
// Accepted values: debug, info, warn, error.
// Env: SQI_LOG_LEVEL
Level string `yaml:"level"`
// Format selects the log output format.
// Accepted values: json, text.
// Env: SQI_LOG_FORMAT
Format string `yaml:"format"`
// File, when set, sends log output to this file instead of stderr,
// rotated by size. Relative paths resolve against the working directory
// (a Windows service runs in its config file's directory). Empty keeps
// stderr. When sqi-server runs as a Windows service with File empty, logs
// go to %ProgramData%\sqi\logs\<service-name>.log.
// Env: SQI_LOG_FILE
File string `yaml:"file"`
// MaxSizeMB is the size in megabytes at which File is rotated. Must be > 0.
// Env: SQI_LOG_MAX_SIZE_MB
MaxSizeMB int `yaml:"max_size_mb"`
// MaxBackups is how many rotated files (File.1 … File.N) are kept; 0
// keeps none. Must be >= 0.
// Env: SQI_LOG_MAX_BACKUPS
MaxBackups int `yaml:"max_backups"`
}
LogConfig controls structured log output.
type NATSAuthConfig ¶ added in v0.4.0
type NATSAuthConfig struct {
// Enabled requires every NATS client to present a per-worker nkey
// credential. When false, the default, the broker accepts any anonymous
// connection and refuses one that presents a key.
// Env: SQI_NATS_AUTH_ENABLED
Enabled bool `yaml:"enabled"`
// JoinTokenTTL is how long a newly issued worker join token remains
// valid. Bounded by MinNATSAuthJoinTokenTTL and MaxNATSAuthJoinTokenTTL.
// Env: SQI_NATS_AUTH_JOIN_TOKEN_TTL
JoinTokenTTL time.Duration `yaml:"join_token_ttl"`
// JoinTokenSingleUse consumes a join token on first successful
// enrollment. Leave it true unless image-baked fleets enroll many
// identical machines from one token.
// Env: SQI_NATS_AUTH_JOIN_TOKEN_SINGLE_USE
JoinTokenSingleUse bool `yaml:"join_token_single_use"`
// EnrollmentEndpointEnabled mounts POST /api/v1/workers/enroll. Set it
// false at a site that provisions every credential by hand and wants no
// enrollment surface at all. Meaningful only when Enabled is true.
// Env: SQI_NATS_AUTH_ENROLLMENT_ENDPOINT_ENABLED
EnrollmentEndpointEnabled bool `yaml:"enrollment_endpoint_enabled"`
// UserTTL is the lifetime of the user JWT issued to a worker. Bounded by
// MinNATSAuthUserTTL and MaxNATSAuthUserTTL.
// Env: SQI_NATS_AUTH_USER_TTL
UserTTL time.Duration `yaml:"user_ttl"`
}
NATSAuthConfig configures broker authentication and worker enrollment.
type NATSCalloutConfig ¶ added in v0.4.0
type NATSCalloutConfig struct {
// NkeySeedFile is the callout connection's own user nkey seed, in the
// AUTH account.
// Env: SQI_NATS_EXTERNAL_CALLOUT_NKEY_SEED_FILE
NkeySeedFile string `yaml:"nkey_seed_file"`
// IssuerSeedFile is the account nkey seed sqi signs callout responses
// with.
// Env: SQI_NATS_EXTERNAL_CALLOUT_ISSUER_SEED_FILE
IssuerSeedFile string `yaml:"issuer_seed_file"`
// SystemCredsFile is an optional system-account credential; it enables
// immediate revocation by kicking the connection.
// Env: SQI_NATS_EXTERNAL_CALLOUT_SYSTEM_CREDS_FILE
SystemCredsFile string `yaml:"system_creds_file"`
}
NATSCalloutConfig configures the auth callout connection to an external broker.
type NATSClientTLSConfig ¶ added in v0.4.0
type NATSClientTLSConfig struct {
// CAFile is the PEM CA bundle that verifies the broker's certificate.
// Env: SQI_NATS_EXTERNAL_TLS_CA_FILE
CAFile string `yaml:"ca_file"`
// CertFile is an optional client certificate, for clusters that require
// mTLS.
// Env: SQI_NATS_EXTERNAL_TLS_CERT_FILE
CertFile string `yaml:"cert_file"`
// KeyFile is the private key matching CertFile.
// Env: SQI_NATS_EXTERNAL_TLS_KEY_FILE
KeyFile string `yaml:"key_file"`
// ServerName overrides the name the broker certificate is verified
// against.
// Env: SQI_NATS_EXTERNAL_TLS_SERVER_NAME
ServerName string `yaml:"server_name"`
}
NATSClientTLSConfig is the TLS configuration of a client connection to an external broker.
type NATSConfig ¶
type NATSConfig struct {
// Mode selects the broker: "embedded" (the default) or "external".
// Env: SQI_NATS_MODE
Mode string `yaml:"mode"`
// Auth configures per-worker broker authentication. Off by default, and
// the same in both modes. Independent of the top-level auth block: the
// two protect different surfaces, so worker authentication does not
// require user accounts.
Auth NATSAuthConfig `yaml:"auth"`
// Embedded configures the broker inside sqi-server. Used only when Mode
// is embedded.
Embedded NATSEmbeddedConfig `yaml:"embedded"`
// External configures the connection to an operator-run broker. Used
// only when Mode is external.
External NATSExternalConfig `yaml:"external"`
}
NATSConfig controls the NATS JetStream broker sqi runs on: either one embedded in sqi-server or an external server or cluster.
type NATSEmbeddedConfig ¶ added in v0.4.0
type NATSEmbeddedConfig struct {
// Addr is the TCP address the embedded NATS server binds to. The default,
// 0.0.0.0:4222, listens on every interface because workers connect to the
// broker over the network; sqi-server itself uses NATS in-process.
// Env: SQI_NATS_EMBEDDED_ADDR
Addr string `yaml:"addr"`
// AdvertiseURL is the broker URL discovery tells workers to use. Empty
// derives nats:// or tls:// from the discovery host and Addr's port.
// Env: SQI_NATS_EMBEDDED_ADVERTISE_URL
AdvertiseURL string `yaml:"advertise_url"`
// DataDir is the directory used by JetStream for file-backed stream
// storage. Created at startup if it does not exist.
// Env: SQI_NATS_EMBEDDED_DATA_DIR
DataDir string `yaml:"data_dir"`
// MaxStoreMB is the JetStream file-storage cap in megabytes.
// Env: SQI_NATS_EMBEDDED_MAX_STORE_MB
MaxStoreMB int `yaml:"max_store_mb"`
// TLS encrypts the embedded broker's client listener. Off by default.
TLS NATSTLSConfig `yaml:"tls"`
}
NATSEmbeddedConfig configures the broker embedded in sqi-server.
type NATSExternalConfig ¶ added in v0.4.0
type NATSExternalConfig struct {
// URLs are the broker URLs sqi-server connects to, all tls:// or all
// nats://. Required in external mode.
// Env: SQI_NATS_EXTERNAL_URLS (comma-separated)
URLs []string `yaml:"urls"`
// AdvertiseURLs are the broker URLs discovery tells workers to use.
// Empty means URLs.
// Env: SQI_NATS_EXTERNAL_ADVERTISE_URLS (comma-separated)
AdvertiseURLs []string `yaml:"advertise_urls"`
// Account is the dedicated NATS account sqi's streams, consumers and
// workers live in.
// Env: SQI_NATS_EXTERNAL_ACCOUNT
Account string `yaml:"account"`
// NkeySeedFile is sqi-server's data-connection credential as an nkey
// seed. Mutually exclusive with CredsFile; neither set means an
// unauthenticated account.
// Env: SQI_NATS_EXTERNAL_NKEY_SEED_FILE
NkeySeedFile string `yaml:"nkey_seed_file"`
// CredsFile is sqi-server's data-connection credential as a .creds file.
// Mutually exclusive with NkeySeedFile.
// Env: SQI_NATS_EXTERNAL_CREDS_FILE
CredsFile string `yaml:"creds_file"`
// StreamReplicas is the JetStream replica count for sqi's streams and
// KV bucket: 1, 3 or 5.
// Env: SQI_NATS_EXTERNAL_STREAM_REPLICAS
StreamReplicas int `yaml:"stream_replicas"`
// ConnectTimeout bounds the connection attempt at startup only;
// reconnects after startup are unbounded.
// Env: SQI_NATS_EXTERNAL_CONNECT_TIMEOUT
ConnectTimeout time.Duration `yaml:"connect_timeout"`
// TLS configures the client side of the connection.
TLS NATSClientTLSConfig `yaml:"tls"`
// Callout configures the auth callout connection. Used only when
// nats.auth.enabled is true.
Callout NATSCalloutConfig `yaml:"callout"`
}
NATSExternalConfig configures sqi-server's connection to an external NATS server or cluster.
func (NATSExternalConfig) MarshalYAML ¶ added in v0.4.0
func (e NATSExternalConfig) MarshalYAML() (any, error)
MarshalYAML replaces the credentials a broker URL may carry (user:password@ or a token@) so they never appear in YAML output (e.g. `sqi-server config print`), as PostgresStoreConfig.MarshalYAML does the DSN's password. It does not affect unmarshaling or the loaded value.
type NATSTLSConfig ¶ added in v0.4.0
type NATSTLSConfig struct {
// Enabled requires TLS on every broker connection.
// Env: SQI_NATS_EMBEDDED_TLS_ENABLED
Enabled bool `yaml:"enabled"`
// CertFile is the PEM certificate presented to connecting workers.
// Env: SQI_NATS_EMBEDDED_TLS_CERT_FILE
CertFile string `yaml:"cert_file"`
// KeyFile is the PEM private key matching CertFile.
// Env: SQI_NATS_EMBEDDED_TLS_KEY_FILE
KeyFile string `yaml:"key_file"`
// ClientCAFile, when set, requires every worker to present a client
// certificate signed by this CA. It is a transport control layered on
// the per-worker nkey credential: the certificate decides who may open a
// connection, the nkey decides which worker it is.
// Env: SQI_NATS_EMBEDDED_TLS_CLIENT_CA_FILE
ClientCAFile string `yaml:"client_ca_file"`
}
NATSTLSConfig controls TLS on the embedded broker. It is separate from the http.tls block because the two protect different surfaces: an operator may use a publicly issued certificate on the API and a private farm CA on the broker.
type NamedPath ¶ added in v0.4.0
type NamedPath struct{ Key, Path string }
NamedPath is one file or directory a configuration names, with the dotted YAML key that names it.
type OIDCConfig ¶ added in v0.3.0
type OIDCConfig struct {
// Enabled turns on SSO. Requires auth.enabled.
// Env: SQI_AUTH_OIDC_ENABLED
Enabled bool `yaml:"enabled"`
// Issuer is the provider's discovery root, e.g.
// https://login.microsoftonline.com/<tenant>/v2.0. Discovery is
// performed lazily on first use, not at boot: a briefly unreachable
// provider must not stop the scheduler from starting.
// Env: SQI_AUTH_OIDC_ISSUER
Issuer string `yaml:"issuer"`
// ClientID is the application's registered identifier.
// Env: SQI_AUTH_OIDC_CLIENT_ID
ClientID string `yaml:"client_id"`
// ClientSecret is the application's secret. Never logged: redacted by
// [OIDCConfig.MarshalYAML] whenever the config is re-marshaled.
// Env: SQI_AUTH_OIDC_CLIENT_SECRET
ClientSecret string `yaml:"client_secret"`
// RedirectURL is the absolute callback URL registered with the
// provider. Must resolve to this server's
// /api/v1/auth/oidc/callback.
// Env: SQI_AUTH_OIDC_REDIRECT_URL
RedirectURL string `yaml:"redirect_url"`
// Scopes requested at authorization. Must include "openid". "groups" is
// not a standard OIDC scope: whether group membership needs a scope, a
// provider-side mapper, or both varies by vendor.
// Env: SQI_AUTH_OIDC_SCOPES (comma-separated)
Scopes []string `yaml:"scopes"`
// UsernameClaim names the claim holding the login name. Used for
// display and uniqueness only — accounts are matched on "sub".
// Env: SQI_AUTH_OIDC_USERNAME_CLAIM
UsernameClaim string `yaml:"username_claim"`
// DisplayNameClaim names the claim holding the human-facing name. Read
// only at provisioning; never overwritten afterwards.
// Env: SQI_AUTH_OIDC_DISPLAY_NAME_CLAIM
DisplayNameClaim string `yaml:"display_name_claim"`
// GroupsClaim names the claim holding group memberships, fed to
// RoleMap.
// Env: SQI_AUTH_OIDC_GROUPS_CLAIM
GroupsClaim string `yaml:"groups_claim"`
// RoleSource decides who owns an OIDC user's role: "directory"
// (recomputed from claims on every login; the users API rejects role
// edits) or "local" (claims seed it at provisioning only). Separate
// from auth.ldap.role_source because an operator may trust one
// provider's groups and not the other's.
// Env: SQI_AUTH_OIDC_ROLE_SOURCE
RoleSource string `yaml:"role_source"`
// RoleMap maps group claims to roles, first match wins. Order
// expresses precedence. File-only: a list of pairs has no sane env
// encoding.
RoleMap []RoleMappingConfig `yaml:"role_map"`
// DefaultRole applies when no group matches. Empty means reject the
// login.
// Env: SQI_AUTH_OIDC_DEFAULT_ROLE
DefaultRole string `yaml:"default_role"`
// ReauthMode controls when the provider is told to re-prompt for
// credentials (prompt=login):
// - "after_logout" (default): only on the login following an
// explicit logout, so "log out" means the next person at a shared
// workstation must authenticate.
// - "always": every login. A hard guarantee, at the cost of SSO's
// convenience.
// - "never": silent re-login always permitted.
// Env: SQI_AUTH_OIDC_REAUTH_MODE
ReauthMode string `yaml:"reauth_mode"`
// LogoutMode controls whether logging out of sqi also ends the session
// at the provider ("provider") or only locally ("local", default).
// Provider logout signs the user out of every company tool, so it is
// off unless asked for.
// Env: SQI_AUTH_OIDC_LOGOUT_MODE
LogoutMode string `yaml:"logout_mode"`
// PostLogoutRedirectURL is where the provider returns the browser
// after a provider-side logout. Must be registered with the provider.
// Only read when LogoutMode is "provider".
// Env: SQI_AUTH_OIDC_POST_LOGOUT_REDIRECT_URL
PostLogoutRedirectURL string `yaml:"post_logout_redirect_url"`
// ButtonLabel is the login page's SSO button text.
// Env: SQI_AUTH_OIDC_BUTTON_LABEL
ButtonLabel string `yaml:"button_label"`
}
OIDCConfig configures OAuth2/OIDC single sign-on.
OIDC is a login-time verifier, not a per-request authenticator: the callback validates the ID token once and then mints the same server-side session a local password login produces. Nothing downstream — RBAC, owner binding, WebSocket scoping — is aware SSO exists.
It is a single provider block, not a list: most organizations have one identity provider, and configuration shape is costly to change because it lives in operators' files. Several providers would be an auth.oidc.providers list alongside these fields, with these fields read as a one-element list; reshaping these fields into a list would break every existing config.
func (OIDCConfig) MarshalYAML ¶ added in v0.3.0
func (o OIDCConfig) MarshalYAML() (any, error)
MarshalYAML redacts ClientSecret so it never appears in YAML output (e.g. `sqi-server config print`). As with LDAPConfig.MarshalYAML, a redacted dump does not round-trip.
type OpenJDConfig ¶
type OpenJDConfig struct {
// EnforceLimits gates quantitative limit validation (maximum name lengths,
// counts, reserved-name rules). Disable it only for templates that exceed
// these limits and cannot be changed.
// Env: SQI_OPENJD_ENFORCE_LIMITS
EnforceLimits bool `yaml:"enforce_limits"`
// ExprOperationLimit is how many OpenJD expression-language operations
// (specification section 1.3.10) one expression in a submitted template may
// spend at validation time.
//
// Raising it lengthens the worst request this server can be asked to
// serve, roughly in proportion: an operation's real cost varies by orders
// of magnitude between arithmetic and a regex over a large string, and
// only ExprSubmissionDeadline bounds wall-clock time.
// Range: [MinOpenJDExprOperationLimit, MaxOpenJDExprOperationLimit].
// Env: SQI_OPENJD_EXPR_OPERATION_LIMIT
ExprOperationLimit int64 `yaml:"expr_operation_limit"`
// ExprMemoryLimit is how many live bytes (specification section 1.3.9) one
// expression in a submitted template may hold at validation time.
//
// Raising it permits proportionally more memory per evaluation on a
// request path that may be unauthenticated, so the ceiling is one order
// of magnitude above the default. No other internal guard caps a larger
// value: the ceiling is a policy limit, not a point beyond which the
// setting stops having an effect.
// Range: [MinOpenJDExprMemoryLimit, MaxOpenJDExprMemoryLimit].
// Env: SQI_OPENJD_EXPR_MEMORY_LIMIT
ExprMemoryLimit int64 `yaml:"expr_memory_limit"`
// ExprTemplatePositions is how many expression positions one template may
// contain, counted across the whole validation pass rather than per field.
//
// This and ExprOperationLimit multiply: the cumulative operation ceiling
// for one request is their product.
//
// A worker's per-assignment position cap must not be lower than this, or
// a job this server accepts fails on every task at run time. The
// scheduler withholds EXPR work from a worker whose caps are lower.
// Range: [MinOpenJDExprTemplatePositions, MaxOpenJDExprTemplatePositions].
// Env: SQI_OPENJD_EXPR_TEMPLATE_POSITIONS
ExprTemplatePositions int64 `yaml:"expr_template_positions"`
// ExprTemplateRetainedBytes is how many bytes a template's `let:` bindings
// may cumulatively retain across one validation pass.
//
// It counts cumulative allocation, not peak live retention: a template
// that never holds more than a few MB at once is still charged the sum of
// every block, so sizing a host's RAM against this number over-provisions.
// Range: [MinOpenJDExprTemplateRetainedBytes, MaxOpenJDExprTemplateRetainedBytes].
// Env: SQI_OPENJD_EXPR_TEMPLATE_RETAINED_BYTES
ExprTemplateRetainedBytes int64 `yaml:"expr_template_retained_bytes"`
// ExprSubmissionDeadline is how long this server keeps evaluating one
// submission's expressions before giving up on it.
//
// The four limits above are deterministic: a template that breaches one
// breaches it on every machine, so the submitter is told the template is
// invalid (a 422). This one is wall-clock time, so the same body can be
// accepted on an idle host and rejected on a loaded one; a breach reports
// that this server gave up (a 503 a retry may clear), not that the
// template is wrong.
//
// It is the only bound on time. Specification section 1.3.10 prices 256
// bytes at one operation, so byte-heavy work is cheap in operations and
// expensive in seconds; with every other limit respected, one request can
// cost more than 15 minutes of server CPU at the defaults.
// Range: [MinOpenJDExprSubmissionDeadline, MaxOpenJDExprSubmissionDeadline].
// Env: SQI_OPENJD_EXPR_SUBMISSION_DEADLINE
ExprSubmissionDeadline time.Duration `yaml:"expr_submission_deadline"`
}
OpenJDConfig controls OpenJD submission and validation behavior.
type PostgresStoreConfig ¶ added in v0.4.0
type PostgresStoreConfig struct {
// DSN is the connection string, in URL (postgres://user:pass@host/db) or
// keyword/value (host=… dbname=…) form. Its password is redacted in YAML
// output.
// Env: SQI_STORE_POSTGRES_DSN
DSN string `yaml:"dsn"`
// MaxConns is the write pool's size; one connection holds the
// single-server lock. 2–1000.
// Env: SQI_STORE_POSTGRES_MAX_CONNS
MaxConns int `yaml:"max_conns"`
}
PostgresStoreConfig configures the PostgreSQL store.
func (PostgresStoreConfig) MarshalYAML ¶ added in v0.4.0
func (p PostgresStoreConfig) MarshalYAML() (any, error)
MarshalYAML redacts the DSN's password so it never appears in YAML output (e.g. `sqi-server config print`), as LDAPConfig.MarshalYAML does the bind password. It does not affect unmarshaling or the loaded value. A redacted dump does not round-trip.
type PresetLibraryConfig ¶ added in v0.2.0
type PresetLibraryConfig struct {
// URL is the library's JSON index URL (the raw index file, not a repo page).
// Empty disables the feature. Default: the official sqi preset library.
// Env: SQI_PRESET_LIBRARY_URL
URL string `yaml:"url"`
}
PresetLibraryConfig controls the community preset library integration.
type RateLimitConfig ¶ added in v0.4.0
type RateLimitConfig struct {
// Enabled applies the per-IP rate limit to API requests. On by default.
// Turn it off only behind a trusted network or for load testing: with it
// off nothing throttles a client that floods the API.
// Env: SQI_HTTP_RATE_LIMIT_ENABLED
Enabled bool `yaml:"enabled"`
}
RateLimitConfig controls the per-IP rate limit on the HTTP API.
type RoleMappingConfig ¶ added in v0.3.0
RoleMappingConfig is one group-DN → role rule.
type SchedulerConfig ¶
type SchedulerConfig struct {
// HeartbeatTimeout is the duration after which a worker that has not sent
// a heartbeat is declared offline and its in-flight tasks are reclaimed.
// Env: SQI_SCHEDULER_HEARTBEAT_TIMEOUT
HeartbeatTimeout time.Duration `yaml:"heartbeat_timeout"`
// TickInterval is how often the assignment loop wakes to match ready tasks
// to available workers.
// Env: SQI_SCHEDULER_TICK_INTERVAL
TickInterval time.Duration `yaml:"tick_interval"`
// MaxTasksPerWorker caps the number of tasks that can be simultaneously
// assigned to a single worker. Must be ≥ 1.
// Env: SQI_SCHEDULER_MAX_TASKS_PER_WORKER
MaxTasksPerWorker int `yaml:"max_tasks_per_worker"`
// OfflineWorkerRetention is how long a worker may stay offline before the
// retention sweep hard-deletes it, bounding worker-table growth on farms
// with ephemeral nodes. Disabled and online workers are never auto-removed.
// Set to 0 to disable automatic removal. Default: 24h.
// Env: SQI_SCHEDULER_OFFLINE_WORKER_RETENTION
OfflineWorkerRetention time.Duration `yaml:"offline_worker_retention"`
// JobRetention is how long a terminal job is kept before the retention
// sweep hard-deletes it and all of its data. completed and canceled jobs
// are always eligible; failed jobs only when JobRetentionIncludeFailed is
// set. Set to 0 to disable automatic deletion. Default: 168h (7 days).
// Env: SQI_SCHEDULER_JOB_RETENTION
JobRetention time.Duration `yaml:"job_retention"`
// JobRetentionIncludeFailed extends the retention sweep to failed jobs.
// Default: false. Env: SQI_SCHEDULER_JOB_RETENTION_INCLUDE_FAILED
JobRetentionIncludeFailed bool `yaml:"job_retention_include_failed"`
// UnschedulableGrace is how long a ready task may wait with no eligible
// online worker before it is flagged unschedulable. 0 disables the sweep.
// Default: 30s. Env: SQI_SCHEDULER_UNSCHEDULABLE_GRACE
UnschedulableGrace time.Duration `yaml:"unschedulable_grace"`
// ReconcileGrace is how long a live worker may go without reporting, in
// its heartbeats, an attempt it holds before the heartbeat sweep reclaims
// that attempt and the task runs again (a lost completion report, a
// restored database). 0 disables reconciliation; any other value must be
// at least HeartbeatTimeout. Default: 2m, or HeartbeatTimeout when that is
// longer and this key is set neither in the file nor in the environment
// (the loader applies that; [DefaultConfig] returns 2m).
// Env: SQI_SCHEDULER_RECONCILE_GRACE
ReconcileGrace time.Duration `yaml:"reconcile_grace"`
// DefaultMaxAttempts is the server-level fallback for the farm-wide default
// number of attempts a task may make before going terminal-failed. It is the
// bottom tier of the layered retry policy (Server -> Farm -> Queue -> Job).
// Must be >= 1; 1 disables auto-retry. Default: 3.
// Env: SQI_SCHEDULER_DEFAULT_MAX_ATTEMPTS
DefaultMaxAttempts int `yaml:"default_max_attempts"`
// RetryDelay is the server-level fallback default backoff before a failed
// task re-enters the ready queue. 0 = immediate. Default: 30s.
// Env: SQI_SCHEDULER_RETRY_DELAY
RetryDelay time.Duration `yaml:"retry_delay"`
// DefaultFailureLimit is the server-level fallback default job-level
// failure ceiling. 0 = off (no auto-park). Default: 0.
// Env: SQI_SCHEDULER_DEFAULT_FAILURE_LIMIT
DefaultFailureLimit int `yaml:"default_failure_limit"`
}
SchedulerConfig controls the scheduler: task assignment, worker liveness, retention, retries and reconciliation.
type SessionConfig ¶ added in v0.3.0
type SessionConfig struct {
// TTL is the absolute session lifetime; there is no sliding/idle renewal.
// Env: SQI_AUTH_SESSION_TTL
TTL time.Duration `yaml:"ttl"`
// CookieName is the session cookie name. Must match
// session.DefaultCookieName in internal/auth/session.
// Env: SQI_AUTH_SESSION_COOKIE_NAME
CookieName string `yaml:"cookie_name"`
// CookieSecure controls the cookie's Secure attribute. One of:
// - "auto" (default): Secure when the request arrived over TLS or with
// X-Forwarded-Proto: https.
// - "true": always Secure.
// - "false": never Secure — for plain-HTTP LAN deployments.
// Env: SQI_AUTH_SESSION_COOKIE_SECURE
CookieSecure string `yaml:"cookie_secure"`
}
SessionConfig controls server-side session cookies.
type Sources ¶ added in v0.4.0
type Sources struct {
// StoreSQLitePath is true when store.sqlite_path was set by the config
// file or by SQI_STORE_SQLITE_PATH.
StoreSQLitePath bool
// StoreCheckpointInterval is true when store.checkpoint_interval was set
// by the config file or by SQI_STORE_CHECKPOINT_INTERVAL.
StoreCheckpointInterval bool
// SchedulerReconcileGrace is true when scheduler.reconcile_grace was set
// by the config file or by SQI_SCHEDULER_RECONCILE_GRACE. When it was not,
// the loader resolves it to the larger of its default and
// scheduler.heartbeat_timeout (see [resolveReconcileGrace]).
SchedulerReconcileGrace bool
}
Sources reports, for a subset of settings, whether the config file or environment layer explicitly decided the value — as opposed to it being the built-in default that nothing overrode.
Comparing a resolved value against DefaultConfig's cannot answer this: a config file (or the shipped config/sqi-server.example.yaml) can restate a default value, and value comparison cannot tell "set to the default" from "never set". Sources is built from the file and environment layers themselves, before defaults are filled in.
type StoreConfig ¶
type StoreConfig struct {
// Driver selects the store: "sqlite" (the default, embedded) or
// "postgres" (an external PostgreSQL 16 or later).
// Env: SQI_STORE_DRIVER
Driver string `yaml:"driver"`
// SQLitePath is the path to the SQLite database file.
// Created at startup if it does not exist.
// Ignored when Driver is postgres.
// Env: SQI_STORE_SQLITE_PATH
SQLitePath string `yaml:"sqlite_path"`
// CheckpointInterval is how often the background goroutine runs a WAL
// checkpoint (PRAGMA wal_checkpoint(PASSIVE)) to fold committed WAL frames
// back into the main database file and keep the WAL from growing unboundedly.
// The periodic checkpoint is PASSIVE so it never waits on a reader; the
// TRUNCATE checkpoint runs only on clean shutdown.
// Must be > 0. Set to a large value (e.g. "24h") to effectively disable
// periodic checkpointing (a final checkpoint always runs on shutdown).
// Ignored when Driver is postgres.
// Env: SQI_STORE_CHECKPOINT_INTERVAL
CheckpointInterval time.Duration `yaml:"checkpoint_interval"`
// Postgres configures the PostgreSQL store. Used only when Driver is
// postgres.
Postgres PostgresStoreConfig `yaml:"postgres"`
}
StoreConfig controls the state store: the embedded SQLite database (the default) or an external PostgreSQL server.
type TLSConfig ¶ added in v0.4.0
type TLSConfig struct {
// Enabled turns the listener into an HTTPS listener. There is no
// plaintext port when it is on: the same address serves HTTPS.
// Env: SQI_HTTP_TLS_ENABLED
Enabled bool `yaml:"enabled"`
// CertFile is the PEM certificate (leaf first, then any intermediates).
// Env: SQI_HTTP_TLS_CERT_FILE
CertFile string `yaml:"cert_file"`
// KeyFile is the PEM private key matching CertFile.
// Env: SQI_HTTP_TLS_KEY_FILE
KeyFile string `yaml:"key_file"`
}
TLSConfig controls in-process TLS termination for a listener. The zero value, the default, leaves TLS off and the listener serves plain HTTP.
type ValidationError ¶
type ValidationError struct {
// Field is the dot-separated config path, e.g. "http.addr" or
// "scheduler.max_tasks_per_worker". It mirrors the YAML key hierarchy.
Field string
// Message describes what is wrong and how to correct it.
Message string
}
ValidationError describes a single configuration error with the field path that is invalid and an actionable message explaining how to fix it.
func Validate ¶
func Validate(cfg Config) []ValidationError
Validate checks cfg for missing or invalid values. It returns all violations found in a single pass so callers can report every problem at once rather than failing on the first one.
A nil or empty slice means the configuration is valid.
func (ValidationError) Error ¶
func (e ValidationError) Error() string
type WakeOnLANConfig ¶ added in v0.4.0
type WakeOnLANConfig struct {
// Port is the UDP port magic packets are sent to. 1–65535, default 9.
Port int `yaml:"port"`
// SendTo lists extra "ip:port" targets, each an IPv4 literal, such as a
// router's directed broadcast address, for machines the server's own
// broadcast does not reach.
SendTo []string `yaml:"send_to"`
}
WakeOnLANConfig configures the built-in wake-on-LAN provider.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package pathseedtest checks that a configuration's NamedPaths covers every path-valued field of its struct, for the server's and the worker's tests.
|
Package pathseedtest checks that a configuration's NamedPaths covers every path-valued field of its struct, for the server's and the worker's tests. |