Documentation
¶
Overview ¶
Package config loads Astrate's single TOML configuration file with ASTRATE_* environment overrides (docs/DESIGN.md §5.1, ROADMAP §9 file 8.1). Precedence is default < TOML < environment. Zero-config defaults target the single-VPS case: only a database DSN and (outside dev mode) the broker's TLS identity must be supplied. The master encryption key is referenced here but read by internal/store (env or file), never inlined.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
HTTP HTTPConfig `toml:"http"`
MQTT MQTTConfig `toml:"mqtt"`
Database DatabaseConfig `toml:"database"`
Engine EngineConfig `toml:"engine"`
Pairing PairingConfig `toml:"pairing"`
Housekeeping HousekeepingConfig `toml:"housekeeping"`
Storage StorageConfig `toml:"storage"`
Security SecurityConfig `toml:"security"`
Realm RealmConfig `toml:"realm"`
Log LogConfig `toml:"log"`
Triggers TriggersConfig `toml:"triggers"`
}
Config is the whole Astrate configuration.
func Default ¶
func Default() Config
Default returns the zero-config defaults (single-VPS, dev-friendly).
func Load ¶
Load reads the config: defaults, then the TOML file at path (skipped when path is empty — env-only operation), then ASTRATE_* env overrides, then validation. The returned Config is ready to wire.
func (*Config) HousekeepingKeys ¶
HousekeepingKeys resolves the instance-admin JWT public keys, reading any referenced files and appending them to the inline blocks.
func (*Config) RealmJWTPublicKey ¶
RealmJWTPublicKey resolves the auto-provision realm's JWT public key, preferring the inline block over the file reference.
type DatabaseConfig ¶
type DatabaseConfig struct {
DSN string `toml:"dsn"`
}
DatabaseConfig is the PostgreSQL/TimescaleDB connection.
type Duration ¶
Duration is a time.Duration that (un)marshals as a Go duration string ("50ms", "720h") in TOML — time.Duration itself is not a TextUnmarshaler.
func (Duration) MarshalText ¶
MarshalText renders the duration as a Go duration string.
func (*Duration) UnmarshalText ¶
UnmarshalText parses a Go duration string.
type EngineConfig ¶
type EngineConfig struct {
Shards int `toml:"shards"`
ShardQueue int `toml:"shard_queue"`
BatchMaxRows int `toml:"batch_max_rows"`
BatchMaxWait Duration `toml:"batch_max_wait"`
MaxPayloadBytes int `toml:"max_payload_bytes"`
}
EngineConfig tunes the ingestion pipeline (§1.4).
type ForwardConfig ¶ added in v0.2.0
type ForwardConfig struct {
Kind string `toml:"kind"`
URL string `toml:"url"`
Method string `toml:"method"`
StaticHeaders map[string]string `toml:"static_headers"`
// Subject is the NATS subject every custom action is published to.
// Required when Kind is "nats"; unused otherwise.
Subject string `toml:"subject"`
}
ForwardConfig selects the Forwarder that receives trigger actions which are not HTTP webhooks (docs/DESIGN.md §1.1). Kind "" disables forwarding entirely; "http" selects the HTTP bus forwarder; "nats" selects the NATS bus forwarder (only usable in a binary built with -tags nats — see cmd/astrate/newnats_*.go).
type HTTPConfig ¶
type HTTPConfig struct {
Addr string `toml:"addr"`
TLSCertFile string `toml:"tls_cert_file"`
TLSKeyFile string `toml:"tls_key_file"`
CORSAllowedOrigins []string `toml:"cors_allowed_origins"`
}
HTTPConfig is the single REST listener (§3.7). TLS is optional: leave the files empty to serve plaintext behind a TLS-terminating reverse proxy. CORSAllowedOrigins enables cross-origin browser clients (the Astarte Dashboard SPA): each entry is "*" or an absolute origin such as "http://localhost:4040"; empty (the default) disables CORS entirely.
type HousekeepingConfig ¶
type HousekeepingConfig struct {
JWTPublicKeys []string `toml:"jwt_public_keys"`
JWTPublicKeyFiles []string `toml:"jwt_public_key_files"`
// DefaultDatastreamMaximumStorageRetention is the realm-level datastream
// storage ceiling (seconds) injected at realm creation when the caller
// omits the field (#73). When unset (nil) no default is injected and
// existing deployments behave exactly as before.
DefaultDatastreamMaximumStorageRetention *int64 `toml:"default_datastream_maximum_storage_retention"`
// RealmDeletionDisabled gates DELETE /housekeeping/v1/realms/{realm}
// (#75): when true, deletion answers upstream's 405 "Realm deletion
// disabled". Opt-in — unset (false) keeps the historical
// always-delete behavior.
RealmDeletionDisabled bool `toml:"realm_deletion_disabled"`
}
HousekeepingConfig carries the instance-admin JWT public keys (a_ha): either inline PEM blocks or file references; both are concatenated.
type MQTTConfig ¶
type MQTTConfig struct {
Addr string `toml:"addr"`
TLSCertFile string `toml:"tls_cert_file"`
TLSKeyFile string `toml:"tls_key_file"`
InsecureDevMode bool `toml:"insecure_dev_mode"`
DevAddr string `toml:"dev_addr"`
SessionStorePath string `toml:"session_store_path"`
// AdvertisedURL is the broker URL handed to devices by the pairing info
// endpoint. Empty derives "mqtts://<Addr>" (fine for localhost; set it
// explicitly when devices reach the broker by a different host).
AdvertisedURL string `toml:"advertised_url"`
MaxPacketBytes uint32 `toml:"max_packet_bytes"`
}
MQTTConfig is the embedded broker (§3.1).
type PairingConfig ¶
type PairingConfig struct {
CertTTL Duration `toml:"cert_ttl"`
EnforceLatestCert bool `toml:"enforce_latest_cert"`
RegisterRate float64 `toml:"register_rate"`
RegisterBurst int `toml:"register_burst"`
CredentialsRate float64 `toml:"credentials_rate"`
CredentialsBurst int `toml:"credentials_burst"`
BcryptCost int `toml:"bcrypt_cost"`
}
PairingConfig tunes credential issuance and its rate limits (§4.3, §4.5).
type RealmConfig ¶
type RealmConfig struct {
Name string `toml:"name"`
JWTPublicKey string `toml:"jwt_public_key"`
JWTPublicKeyFile string `toml:"jwt_public_key_file"`
DeviceRegistrationLimit *int32 `toml:"device_registration_limit"`
}
RealmConfig optionally auto-provisions a realm on boot (§5.1). Name empty disables it; when set, JWTPublicKey (PEM) is required.
type SecurityConfig ¶
type SecurityConfig struct {
MasterKeyFile string `toml:"master_key_file"`
}
SecurityConfig references the master encryption key that seals realm CA private keys (§4.3). When MasterKeyFile is empty, the store falls back to ASTRATE_MASTER_KEY / ASTRATE_MASTER_KEY_FILE.
type StorageConfig ¶
type StorageConfig struct {
Retention Duration `toml:"retention"`
}
StorageConfig holds runtime storage policy. Retention applies a global TimescaleDB drop-chunks policy; zero (the default) disables it, leaving per-endpoint TTL (§2.5) as the only expiry.
type TriggersConfig ¶ added in v0.2.0
type TriggersConfig struct {
Forward ForwardConfig `toml:"forward"`
}
TriggersConfig groups the trigger engine's knobs.