configuration

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 16 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultGatewayStorageBudget = 1 << 30

DefaultGatewayStorageBudget bounds the database on a gateway unless storage_budget is set; a negative budget is unlimited (LONG-07).

Variables

This section is empty.

Functions

func ByteSizeEnvTypeParser added in v0.8.0

func ByteSizeEnvTypeParser() (reflect.Type, envldr.Parser)

func DefaultNamespaces

func DefaultNamespaces() []model.Namespace

DefaultNamespaces reproduce today's behavior of processes and smart services (NS-02, NS-03, NS-05, NS-06): process models are shareable, deployments and instances of processes belong to their owner; smart service designs belong to their owner, releases and instances are shareable.

func Duration

func Duration(value string) time.Duration

func List

func List(value string) []string

List splits a comma separated value and drops empty entries.

Types

type ByteSize added in v0.8.0

type ByteSize int64

ByteSize is a size in bytes, given as a number of bytes or with a unit, e.g. "1GiB", "500MB" or "1.5GiB", so that a gateway module can offer it readable.

func ParseByteSize added in v0.8.0

func ParseByteSize(text string) (ByteSize, error)

ParseByteSize reads a number with an optional unit: B, kB, MB, GB, TB (powers of 1000) or KiB, MiB, GiB, TiB (powers of 1024), case-insensitive, with or without a space before it.

func (*ByteSize) UnmarshalJSON added in v0.8.0

func (this *ByteSize) UnmarshalJSON(b []byte) error

UnmarshalJSON takes a number of bytes or a string with a unit.

type Config

type Config struct {
	ServerPort int    `json:"server_port" env_var:"SERVER_PORT"`
	LogLevel   string `json:"log_level" env_var:"LOG_LEVEL"`

	// "postgres" or "sqlite"
	Database    string       `json:"database" env_var:"DATABASE"`
	PostgresDsn types.Secret `json:"postgres_dsn" env_var:"POSTGRES_DSN"`
	// open connections per process, 0 for no limit; behind PgBouncer in session mode every open
	// connection holds a server connection of the pool
	PostgresMaxConns int    `json:"postgres_max_conns" env_var:"POSTGRES_MAX_CONNS"`
	SqlitePath       string `json:"sqlite_path" env_var:"SQLITE_PATH"`

	// with a certificate URL, the live stream verifies token signatures, because its token may come
	// as first message and then does not pass Kong (DBG-08); other requests only with verify_tokens,
	// otherwise Kong has verified them (SEC-04)
	// e.g. https://<keycloak>/auth/realms/<realm>/protocol/openid-connect/certs
	KeycloakCertUrl string `json:"keycloak_cert_url" env_var:"KEYCLOAK_CERT_URL"`
	// verify the signatures of the tokens of all requests with keycloak_cert_url, not only those of
	// the live stream; callers that build unsigned tokens, as user-management does, are then refused
	VerifyTokens bool `json:"verify_tokens" env_var:"VERIFY_TOKENS"`

	// time zone for timers; empty uses the local zone of the process (TZ)
	Timezone string `json:"timezone" env_var:"TIMEZONE"`

	MaxTokens                 int    `json:"max_tokens" env_var:"MAX_TOKENS"`
	MaxVariableBytes          int    `json:"max_variable_bytes" env_var:"MAX_VARIABLE_BYTES"`
	MaxInstanceVariablesBytes int    `json:"max_instance_variables_bytes" env_var:"MAX_INSTANCE_VARIABLES_BYTES"`
	MaxActivities             int    `json:"max_activities" env_var:"MAX_ACTIVITIES"`
	MaxRuns                   int    `json:"max_runs" env_var:"MAX_RUNS"` // runs kept per instance with their incidents and element statistics (LONG-03)
	ScriptTimeout             string `json:"script_timeout" env_var:"SCRIPT_TIMEOUT"`
	// shortest timer duration of a model, as process-deployment had it; "0s" allows every one
	MinTimerDuration string `json:"min_timer_duration" env_var:"MIN_TIMER_DURATION"`
	TaskTimeout      string `json:"task_timeout" env_var:"TASK_TIMEOUT"`
	TaskRetries      int    `json:"task_retries" env_var:"TASK_RETRIES"`
	PollInterval     string `json:"poll_interval" env_var:"POLL_INTERVAL"`

	RetentionDefaultDays int `json:"retention_default_days" env_var:"RETENTION_DEFAULT_DAYS"`
	// 0: no global maximum
	RetentionMaxDays  int `json:"retention_max_days" env_var:"RETENTION_MAX_DAYS"`
	ModelVersionsKept int `json:"model_versions_kept" env_var:"MODEL_VERSIONS_KEPT"`

	// empty: no permissions-v2, only owners and admins have access
	PermissionsV2Url string `json:"permissions_v2_url" env_var:"PERMISSIONS_V2_URL"`
	// Keycloak base URL and client for internal calls with client credentials (SEC-03)
	AuthEndpoint     string       `json:"auth_endpoint" env_var:"AUTH_ENDPOINT"`
	AuthClientId     string       `json:"auth_client_id" env_var:"AUTH_CLIENT_ID"`
	AuthClientSecret types.Secret `json:"auth_client_secret" env_var:"AUTH_CLIENT_SECRET"`

	// empty disables the target (INC-02)
	NotifierUrl               string `json:"notifier_url" env_var:"NOTIFIER_URL"`
	DeveloperNotificationsUrl string `json:"developer_notifications_url" env_var:"DEVELOPER_NOTIFICATIONS_URL"`

	// internal port, not routed through Kong: Prometheus metrics (OPS-05) and the HTTP answers
	// of protocol handlers (POST /responses, POST /errors, TASK-05); 0 disables
	InternalPort int `json:"internal_port" env_var:"INTERNAL_PORT"`
	// net/http/pprof under /debug/pprof/ on 127.0.0.1 of this port, reachable only from inside the
	// pod, e.g. with kubectl port-forward; 0 disables
	PprofPort int `json:"pprof_port" env_var:"PPROF_PORT"`
	// with pprof_port: one of this many lock contentions is recorded in the profile "mutex"
	// (runtime.SetMutexProfileFraction); 0 records none. For measurements, not for steady operation.
	PprofMutexFraction int `json:"pprof_mutex_fraction" env_var:"PPROF_MUTEX_FRACTION"`
	// with pprof_port: a blocking event of at least this many nanoseconds is recorded in the
	// profile "block" (runtime.SetBlockProfileRate), 1 records every one; 0 records none
	PprofBlockRate int `json:"pprof_block_rate" env_var:"PPROF_BLOCK_RATE"`
	// running instances without element change for this long count as stalled (LONG-13)
	StalledAfter string `json:"stalled_after" env_var:"STALLED_AFTER"`
	// OTLP collector over gRPC for traces; empty selects the platform default of
	// gin-middleware/otelx, "off" disables tracing
	OtelEndpoint string `json:"otel_endpoint" env_var:"OTEL_ENDPOINT"`

	// api-docs-provider, e.g. http://api.swagger:5000: the cloud engine uploads docs/asyncapi.json on
	// start, as the other platform services do, for API Docs of the web-ui; empty uploads nothing
	ApiDocsProviderBaseUrl string `json:"api_docs_provider_base_url" env_var:"API_DOCS_PROVIDER_BASE_URL"`
	// services and options of the module task types of smart services (TASK-29). On a gateway it is
	// the device-manager of the gateway instead, e.g. http://device-manager:8080: the connection
	// state of devices at start and for the task device_connection (SNRGY-5151); empty makes that
	// task fail. The cloud does not use it for connection states.
	DeviceManagerUrl string `json:"device_manager_url" env_var:"DEVICE_MANAGER_URL"`
	FlowEngineUrl    string `json:"flow_engine_url" env_var:"FLOW_ENGINE_URL"`
	// analytics-flow-repo; flows used by deployments are checked for changes (SMS-15)
	FlowRepoUrl string `json:"flow_repo_url" env_var:"FLOW_REPO_URL"`
	// how often the resources deployments use are checked for changes; "off" or "0" switches it off
	ResourceCheckCycle             string `json:"resource_check_cycle" env_var:"RESOURCE_CHECK_CYCLE"`
	FlowParserUrl                  string `json:"flow_parser_url" env_var:"FLOW_PARSER_URL"`
	ServingServiceUrl              string `json:"serving_service_url" env_var:"SERVING_SERVICE_URL"`
	AnalyticsEnableMultiplePaths   bool   `json:"analytics_enable_multiple_paths" env_var:"ANALYTICS_ENABLE_MULTIPLE_PATHS"`
	AnalyticsDevicePathPrefix      string `json:"analytics_device_path_prefix" env_var:"ANALYTICS_DEVICE_PATH_PREFIX"`
	AnalyticsGroupPathPrefix       string `json:"analytics_group_path_prefix" env_var:"ANALYTICS_GROUP_PATH_PREFIX"`
	AnalyticsImportPathPrefix      string `json:"analytics_import_path_prefix" env_var:"ANALYTICS_IMPORT_PATH_PREFIX"`
	AnalyticsRemoveImportPathRoot  bool   `json:"analytics_remove_import_path_root" env_var:"ANALYTICS_REMOVE_IMPORT_PATH_ROOT"`
	DeviceGroupNamePrefix          string `json:"device_group_name_prefix" env_var:"DEVICE_GROUP_NAME_PREFIX"`
	DeviceGroupAttributeOrigin     string `json:"device_group_attribute_origin" env_var:"DEVICE_GROUP_ATTRIBUTE_ORIGIN"`
	InfoAdditionalModuleDataFields bool   `json:"info_additional_module_data_fields" env_var:"INFO_ADDITIONAL_MODULE_DATA_FIELDS"`
	// watcher task type (TASK-27): requests from models besides device criteria, and intervals
	AllowGenericWatchRequests bool   `json:"allow_generic_watch_requests" env_var:"ALLOW_GENERIC_WATCH_REQUESTS"`
	WatcherMinInterval        string `json:"watcher_min_interval" env_var:"WATCHER_MIN_INTERVAL"`
	WatcherDefaultInterval    string `json:"watcher_default_interval" env_var:"WATCHER_DEFAULT_INTERVAL"`
	// a watch of a device group is checked on announcements of device-repository and, in case
	// one was missed, after this time since its last check (SNRGY-5132)
	WatcherDeviceGroupRecheck string `json:"watcher_device_group_recheck" env_var:"WATCHER_DEVICE_GROUP_RECHECK"`
	// interval of the health checks of modules (SMS-11), and of the check that confirms or clears
	// a finding
	ModuleHealthCheckInterval   string `json:"module_health_check_interval" env_var:"MODULE_HEALTH_CHECK_INTERVAL"`
	ModuleHealthRecheckInterval string `json:"module_health_recheck_interval" env_var:"MODULE_HEALTH_RECHECK_INTERVAL"`

	// live debug streams per user and replica (DBG-10)
	MaxLiveConnectionsPerUser int `json:"max_live_connections_per_user" env_var:"MAX_LIVE_CONNECTIONS_PER_USER"`

	// CORS headers for browser applications that call the engine directly; in the platform Kong
	// sets them. Comma separated origins such as https://ui.example.org, "*" for every origin;
	// empty sets no CORS headers.
	CorsAllowedOrigins string `json:"cors_allowed_origins" env_var:"CORS_ALLOWED_ORIGINS"`
	// comma separated request headers a browser may send to an allowed origin
	CorsAllowedHeaders string `json:"cors_allowed_headers" env_var:"CORS_ALLOWED_HEADERS"`

	// Kafka for device commands, their answers and cache invalidation; empty disables Kafka
	KafkaUrl           string `json:"kafka_url" env_var:"KAFKA_URL"`
	KafkaConsumerGroup string `json:"kafka_consumer_group" env_var:"KAFKA_CONSUMER_GROUP"`
	ResponseTopic      string `json:"response_topic" env_var:"RESPONSE_TOPIC"`
	ErrorTopic         string `json:"error_topic" env_var:"ERROR_TOPIC"`
	// written into each command; the handlers answer there
	MetadataResponseTo string `json:"metadata_response_to" env_var:"METADATA_RESPONSE_TO"`
	MetadataErrorTo    string `json:"metadata_error_to" env_var:"METADATA_ERROR_TO"`
	// any message on these topics clears the device cache; devices and device groups clear their entry
	CacheInvalidationAllTopics []string `json:"cache_invalidation_all_topics" env_var:"CACHE_INVALIDATION_ALL_TOPICS"`
	DeviceTopic                string   `json:"device_topic" env_var:"DEVICE_TOPIC"`
	DeviceGroupTopic           string   `json:"device_group_topic" env_var:"DEVICE_GROUP_TOPIC"`

	// device commands are available when device-repository and marshaller are configured (TASK-01)
	DeviceRepositoryUrl string `json:"device_repository_url" env_var:"DEVICE_REPOSITORY_URL"`
	MarshallerUrl       string `json:"marshaller_url" env_var:"MARSHALLER_URL"`
	// empty: services that only send events cannot be read (TASK-08)
	TimescaleWrapperUrl string `json:"timescale_wrapper_url" env_var:"TIMESCALE_WRAPPER_URL"`
	DeviceSelectionUrl  string `json:"device_selection_url" env_var:"DEVICE_SELECTION_URL"`
	ImportDeployUrl     string `json:"import_deploy_url" env_var:"IMPORT_DEPLOY_URL"`
	// what device-selection offers in deploy dialogs, as in process-deployment (DEP-01)
	DeviceGroupsForTasks  bool `json:"device_groups_for_tasks" env_var:"DEVICE_GROUPS_FOR_TASKS"`
	DeviceGroupsForEvents bool `json:"device_groups_for_events" env_var:"DEVICE_GROUPS_FOR_EVENTS"`
	ImportsForEvents      bool `json:"imports_for_events" env_var:"IMPORTS_FOR_EVENTS"`
	ModifiedDevices       bool `json:"modified_devices" env_var:"MODIFIED_DEVICES"`
	// parallel, sequential or round_robin for device groups (TASK-06)
	GroupScheduler     string `json:"group_scheduler" env_var:"GROUP_SCHEDULER"`
	DeviceCacheTimeout string `json:"device_cache_timeout" env_var:"DEVICE_CACHE_TIMEOUT"`
	// sub-tasks of a sequential or round robin group with an open try at the same time; the
	// element overrides it with senergy:groupConcurrency (SNRGY-5093)
	GroupConcurrency int `json:"group_concurrency" env_var:"GROUP_CONCURRENCY"`

	// engine or event: the event role evaluates device data and correlates events (section 10)
	Role string `json:"role" env_var:"ROLE"`
	// consumer group of event workers, which share the device data topics
	EventConsumerGroup string `json:"event_consumer_group" env_var:"EVENT_CONSUMER_GROUP"`
	// deployments whose waiting instances the event role correlates with a message at the same
	// time; each holds a database connection. 1 correlates one after the other.
	EventCorrelationWorkers int    `json:"event_correlation_workers" env_var:"EVENT_CORRELATION_WORKERS"`
	ImportRepositoryUrl     string `json:"import_repository_url" env_var:"IMPORT_REPOSITORY_URL"`
	// analytics-pipeline, e.g. http://pipeline.analytics:8000: events can wait for the output of an
	// operator of a pipeline (SNRGY-5113); empty rejects such events at deploy
	AnalyticsPipelineUrl string `json:"analytics_pipeline_url" env_var:"ANALYTICS_PIPELINE_URL"`
	// the topic of platform-connector with the connection state of devices (compacted, keyed by
	// device id), which events of the kind device connection read in the cloud (SNRGY-5151)
	DeviceLogTopic string `json:"device_log_topic" env_var:"DEVICE_LOG_TOPIC"`
	// user deletions published by user-management, the fallback for users deleted outside of it (SEC-14)
	UserTopic string `json:"user_topic" env_var:"USER_TOPIC"`
	// permissions-v2 publishes rights changes of the engine topics here; the engine restores
	// the owner's administrate right (SEC-10); empty disables
	PermissionsKafkaTopic string `json:"permissions_kafka_topic" env_var:"PERMISSIONS_KAFKA_TOPIC"`
	// directory of the crash brake, which stops a script that ended the process with a fatal error
	// instead of running it again after the restart (EXPR-03); it has to survive a container
	// restart, e.g. an emptyDir or the volume of a gateway. Empty disables the brake.
	ScriptCrashDir string `json:"script_crash_dir" env_var:"SCRIPT_CRASH_DIR"`
	// how the blocklist compares scripts (EXPR-03): text, the text without // comments, or tree,
	// the syntax tree, which matches any formatting at the cost of a parse per script
	ScriptFingerprint string `json:"script_fingerprint" env_var:"SCRIPT_FINGERPRINT"`

	// cloud or fog; selects the http policy of the namespaces (NS-04) and, in fog, the services
	// of the gateway (FOG-01)
	Mode string `json:"mode" env_var:"MODE"`
	// fog: the broker of the gateway for commands and device events, e.g. tcp://broker:1881
	MqttBroker   string       `json:"mqtt_broker" env_var:"MQTT_BROKER"`
	MqttClientId string       `json:"mqtt_client_id" env_var:"MQTT_CLIENT_ID"`
	MqttUser     string       `json:"mqtt_user" env_var:"MQTT_USER"`
	MqttPassword types.Secret `json:"mqtt_password" env_var:"MQTT_PASSWORD"`
	// fog: mgw-last-value, the last values of event services
	LastValueUrl string `json:"last_value_url" env_var:"LAST_VALUE_URL"`
	// fog: the prefix of the command ids of this engine on the broker of the gateway
	LocalCommandPrefix string `json:"local_command_prefix" env_var:"LOCAL_COMMAND_PREFIX"`
	// fog: concepts for commands before payload version 3 are refreshed at this interval
	ConceptRefreshInterval string `json:"concept_refresh_interval" env_var:"CONCEPT_REFRESH_INTERVAL"`
	// cloud: the broker the gateways reach through mgw-device-cloud-connector; empty disables
	// deployments to gateways (SYNC-04). Replicas share the messages of the gateways in a group.
	SyncMqttBroker   string       `json:"sync_mqtt_broker" env_var:"SYNC_MQTT_BROKER"`
	SyncMqttClientId string       `json:"sync_mqtt_client_id" env_var:"SYNC_MQTT_CLIENT_ID"`
	SyncMqttUser     string       `json:"sync_mqtt_user" env_var:"SYNC_MQTT_USER"`
	SyncMqttPassword types.Secret `json:"sync_mqtt_password" env_var:"SYNC_MQTT_PASSWORD"`
	SyncShareGroup   string       `json:"sync_share_group" env_var:"SYNC_SHARE_GROUP"`
	// unacknowledged desired state goes again after this time (SYNC-08)
	SyncResendAfter string `json:"sync_resend_after" env_var:"SYNC_RESEND_AFTER"`
	// a gateway without status since this time counts as offline
	SyncOfflineAfter string `json:"sync_offline_after" env_var:"SYNC_OFFLINE_AFTER"`
	// how long a read of the history of a gateway waits for its answer (DBG-15)
	SyncCallTimeout string `json:"sync_call_timeout" env_var:"SYNC_CALL_TIMEOUT"`
	// data of a gateway without contact since this time is removed (SYNC-07)
	NetworkCleanupMaxAge string `json:"network_cleanup_max_age" env_var:"NETWORK_CLEANUP_MAX_AGE"`
	// protocol versions of gateways before the own one the cloud serves (SYNC-11)
	SyncProtocolWindow int `json:"sync_protocol_window" env_var:"SYNC_PROTOCOL_WINDOW"`
	// upper bound of the database, in bytes or with a unit such as "1GiB"; 0 is unlimited, in fog
	// 1 GiB, negative unlimited (LONG-07)
	StorageBudget ByteSize `json:"storage_budget" env_var:"STORAGE_BUDGET"`
	// fog: the Postgres of process-io-worker of the old process module; its values are taken
	// over once at the first start (MIG-06)
	LegacyIoPostgres types.Secret `json:"legacy_io_postgres" env_var:"LEGACY_IO_POSTGRES"`
	// fog: the owner of the taken over values; empty keeps the users of process-io
	LegacyIoOwner string `json:"legacy_io_owner" env_var:"LEGACY_IO_OWNER"`
	// fog: the network of the gateway at the cert-manager of the cloud proxy, e.g.
	// http://{gateway}:8080/api/network; its user_id owns the deployments and instances of the
	// gateway (FOG-11). Empty keeps the owners the cloud sends.
	NetworkInfoUrl string `json:"network_info_url" env_var:"NETWORK_INFO_URL"`
	// fog: the HTTP policy of this gateway (NS-04), set by the gateway module so that its owner
	// decides what processes may call. With HTTP_ENABLED set it replaces the fog policy of every
	// namespace that came from the cloud; unset, the namespaces decide. Lists are comma
	// separated; without allow lists, every target no deny list names is allowed.
	HttpEnabled          string `json:"http_enabled" env_var:"HTTP_ENABLED"`
	HttpAllowHosts       string `json:"http_allow_hosts" env_var:"HTTP_ALLOW_HOSTS"`
	HttpDenyHosts        string `json:"http_deny_hosts" env_var:"HTTP_DENY_HOSTS"`
	HttpAllowNetworks    string `json:"http_allow_networks" env_var:"HTTP_ALLOW_NETWORKS"`
	HttpDenyNetworks     string `json:"http_deny_networks" env_var:"HTTP_DENY_NETWORKS"`
	HttpAllowPorts       string `json:"http_allow_ports" env_var:"HTTP_ALLOW_PORTS"`
	HttpTimeout          string `json:"http_timeout" env_var:"HTTP_TIMEOUT"`
	HttpMaxResponseBytes int    `json:"http_max_response_bytes" env_var:"HTTP_MAX_RESPONSE_BYTES"`
	// limits of the process-io store per user (LONG-11)
	MaxIoValuesPerUser int `json:"max_io_values_per_user" env_var:"MAX_IO_VALUES_PER_USER"`
	MaxIoValueBytes    int `json:"max_io_value_bytes" env_var:"MAX_IO_VALUE_BYTES"`

	// seeds namespaces that do not exist yet; afterwards the admin API manages them (NS-02)
	Namespaces []model.Namespace `json:"namespaces" env_var:"NAMESPACES"`
}

func Default

func Default() Config

func Load

func Load(path string) (Config, error)

Load reads the JSON file at path (optional) and then environment variables.

func (Config) LocalHttpPolicy added in v0.5.0

func (this Config) LocalHttpPolicy() (policy model.HttpPolicy, local bool, err error)

LocalHttpPolicy is the HTTP policy the gateway sets for itself; local is false without http_enabled, then the policy of the namespace applies.

func (Config) Location

func (this Config) Location() (*time.Location, error)

func (Config) Logger

func (this Config) Logger() *slog.Logger

Logger writes structured logs. Records logged with a context (InfoContext, ...) carry the baggage of that context and become events of its span.

Jump to

Keyboard shortcuts

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