How configuration works

How the StoatFlow runtime loads configuration — application.yaml on the classpath, overlay files, -D system properties, environment variables and secrets from files — and the layered precedence order.

The :runtime module loads configuration from a layered set of sources: a bundled application.yaml, external overlay files, JVM system properties, and environment variables — merged in a fixed precedence order. Secrets are read from files in a mounted directory. Non-serializable settings (serdes, exception handlers, callbacks) are supplied in code through a streamsConfigOverrides block. This page shows each source, the override forms, and the order in which they win.

For why the model is layered this way — and how it maps onto the engine config versus the runtime infrastructure config — see the configuration model. For the actual keys, see core config and runtime config. For your application's own settings — a database, an API client — see Custom configuration: your sections bind from the same sources, by the same rules.

The config tree

All of StoatFlow's configuration lives under two top-level keys (plus an optional logging):

  • stoatflow: — the stream-processing engine: Kafka connection, lanes, commit barriers, state, changelog, watermarks, licence.
  • runtime: — the runtime infrastructure: HTTP server, metrics, health checks, endpoint visibility.
  • logging: — per-logger levels, overriding logback.xml.

Any other top-level section is your application's own: StoatFlow leaves it alone, and you bind it to a class of yours (see Custom configuration).

A minimal application.yaml only needs an application-id; everything else has a default. Place it on the classpath at src/main/resources/application.yaml:

stoatflow:
  application-id: word-count
  bootstrap-servers: ${KAFKA_BOOTSTRAP_SERVERS:-localhost:9092}

  # The licence comes from STOATFLOW_LICENCE_KEY, ~/.stoatflow/licence.key, or
  # licence.key: ${secret:licence} with a mounted secrets directory.

runtime:
  http:
    enabled: true
    port: ${HTTP_PORT:-8080}
  metrics:
    enabled: true

The loader reads both application.yml and application.yaml from the classpath if present; .yml takes precedence over .yaml when both exist. Both are optional — a config built entirely from environment variables and overlay files is valid as long as stoatflow.application-id resolves.

Placeholders

String values can carry placeholders, resolved once at startup:

PlaceholderResolves to
${VAR}the system property VAR, else the environment variable VAR
${VAR:-default}the same, else default
${env:NAME}the environment variable NAME only
${sys:name}the system property name only
${secret:name}the file name in the secrets directory — see Secrets from files

An unresolved placeholder fails the start only where a value StoatFlow (or your application) binds holds it. A ${prefix:key} whose prefix nothing registered is left as written — which is how a Kafka config-provider reference such as ${file:…} reaches the Kafka client (see Kafka client configuration). Your application can register resolvers of its own, for a vault for example — see Custom configuration.

Placeholders fill in a value inside a file. The override layers below replace a value from outside the file, and win over whatever the file says.

Layered precedence

When the same key is set in more than one place, the highest-priority source wins. From highest to lowest:

#SourceForm
1Environment variablesSTOATFLOW_LANES_COUNT=32
2JVM system properties-Dstoatflow.lanes.count=32
3Overlay files from STOATFLOW_CONFIG_FILES (YAML only, later file wins)STOATFLOW_CONFIG_FILES=/etc/app/base.yaml,/etc/app/prod.yaml
4Bundled application.yml on the classpathsrc/main/resources/application.yml
5Bundled application.yaml on the classpathsrc/main/resources/application.yaml
6Default values in the config data classese.g. runtime.http.port = 8080

Across the files, maps merge key by key — an overlay that sets one Kafka property keeps the others the base file sets — while a list is replaced whole by a later file.

Environment variables

A key's environment variable is its YAML path with every . and - replaced by _, upper-cased:

YAML keyEnvironment variable
stoatflow.application-idSTOATFLOW_APPLICATION_ID
stoatflow.bootstrap-serversSTOATFLOW_BOOTSTRAP_SERVERS
stoatflow.lanes.countSTOATFLOW_LANES_COUNT
stoatflow.commit-barrier.interval-msSTOATFLOW_COMMIT_BARRIER_INTERVAL_MS
stoatflow.validation.pre-flight-consumer-group-checkSTOATFLOW_VALIDATION_PRE_FLIGHT_CONSUMER_GROUP_CHECK
stoatflow.state.dirSTOATFLOW_STATE_DIR
stoatflow.ha.modeSTOATFLOW_HA_MODE
runtime.http.portRUNTIME_HTTP_PORT
stoatflow.licence.keySTOATFLOW_LICENCE_KEY

You escape nothing. StoatFlow knows every key, so it works out where one path segment ends and the next begins: STOATFLOW_COMMIT_BARRIER_INTERVAL_MS can only be commit-barrier.interval-ms. The stoatflow.licence.* variables on Licence configuration are the same rule applied to the licence keys.

Kafka client properties, logger levels and other maps

Four blocks are maps whose keys are data — a Kafka property, a logger name, a validation rule id, a metric tag. In a variable, the part of the name after the map's own path is the entry's key, read in the map's style:

MapA single _ in the key isExampleEntry
stoatflow.kafka.{consumer, producer, restoration-consumer, admin}.STOATFLOW_KAFKA_CONSUMER_MAX_POLL_RECORDS=1000max.poll.records
logging.level.LOGGING_LEVEL_ORG_APACHE_KAFKA_CLIENTS=DEBUGorg.apache.kafka.clients
stoatflow.topology.validation-STOATFLOW_TOPOLOGY_VALIDATION_PRESUMED_CROSS_LANE_READ=errorpresumed-cross-lane-read
runtime.metrics.common-tags_RUNTIME_METRICS_COMMON_TAGS_CLUSTER_NAME=eu-1cluster_name

Inside a map key, whatever the map's style, __ is a literal _ and ___ a literal - (the convention Confluent's images use): STOATFLOW_KAFKA_PRODUCER_APICURIO_REGISTRY_AUTO___REGISTER=true sets the producer's apicurio.registry.auto-register. A run of four or more underscores cannot be read and WARNs. LOGGING_LEVEL_ROOT sets the root logger.

Map keys from variables are lower-cased. A key with capitals — a class-level logger such as com.example.OrderProcessor — goes in YAML, where it is kept as written, or in a -D system property (-Dlogging.level.com.example.OrderProcessor=DEBUG). See Kafka client config for the client maps in full.

Variables that name no key

Every variable that starts with STOATFLOW_, RUNTIME_ or LOGGING_ — or with the name of one of your own sections — and names no key WARNs once at start, with the closest valid name when one is within two edits: STOATFLOW_LANSE_COUNT suggests STOATFLOW_LANES_COUNT, and STOATFLOW_LICENSE_KEY suggests STOATFLOW_LICENCE_KEY. A ConfigMap shared with other tools (Spring's LOGGING_CONFIG, say) therefore WARNs at every start.

The variables StoatFlow's own images and entrypoints read — STOATFLOW_CONFIG_FILES, STOATFLOW_SECRETS_DIR, STOATFLOW_PORT, STOATFLOW_ROCKSDB_MB, STOATFLOW_NON_HEAP_MB and their siblings — are not configuration keys and raise no warning.

In Kubernetes, the variables a Service injects into every pod (<NAME>_SERVICE_HOST, <NAME>_SERVICE_PORT, <NAME>_PORT=tcp://… and their siblings) are skipped. A Service named runtime-http therefore does not set runtime.http.port, while a RUNTIME_HTTP_PORT=9090 you set yourself is kept. You do not need enableServiceLinks: false.

System properties

A -D system property names a key by its YAML path, exactly as written:

java -Dstoatflow.lanes.count=8 \
     -Druntime.http.port=9090 \
     -Dstoatflow.kafka.producer.linger.ms=5 \
     -Dlogging.level.com.example.OrderProcessor=DEBUG \
     -jar app.jar

Map entries are written verbatim, capitals included. System properties sit below environment variables and above every file. The JVM's own properties (java.*, user.*, file.*, os.*, http.* and the like) and org.apache.kafka.* are never read as configuration. The stoatflow.licence.* properties go to the licence check directly, as Licence configuration describes. An unknown name under stoatflow., runtime. or logging. WARNs, like an unknown variable.

Overlay files

For deployment-specific configuration that you don't want baked into the application JAR, set STOATFLOW_CONFIG_FILES to a comma-separated list of file paths. The files are deep-merged on top of the bundled classpath YAML, and later files in the list override earlier ones:

# Single external file
export STOATFLOW_CONFIG_FILES=/etc/myapp/application.yaml

# Multiple files — last wins
export STOATFLOW_CONFIG_FILES=/etc/myapp/base.yaml,/etc/myapp/prod-overrides.yaml

Overlay files are YAML (.yaml or .yml); any other file fails the start (only YAML is supported: /etc/myapp/overrides.properties (STOATFLOW_CONFIG_FILES)). Every file listed is mandatory — if a path doesn't exist, the runtime fails to start with an error naming it. This is the recommended way to inject a Kubernetes ConfigMap into the runtime; secrets go through ${secret:…} instead.

Secrets from files

${secret:name} in any string value reads the file name from the secrets directory — /run/secrets by default, where Docker mounts its secrets. In Kubernetes, mount a Secret volume there and each of its keys becomes a file:

stoatflow:
  licence:
    key: ${secret:licence}
  kafka:
    consumer:
      sasl.jaas.config: ${secret:jaas}
  • The directory. STOATFLOW_SECRETS_DIR moves it. It is a variable, not a YAML key, because placeholders need it before the YAML is read. There is one directory: mount every secret the application reads into it.
  • The name is a file name only — a /, \ or .. is refused.
  • The content is read as UTF-8 with one trailing newline (\n or \r\n) removed, the one kubectl create secret --from-file and most editors leave. Nothing else is trimmed.
  • A missing or unreadable file fails the start with an error naming the path, never the value — and only where a value the application binds holds the placeholder.
  • Read once. Secrets are read at start; a rotated secret takes effect at the next restart.
  • Masked. A value from ${secret:…} is masked in /config, in logs and in error messages.

The deployment side is on Running on Kubernetes and Docker.

Typos and strict mode

StoatFlow checks what it was given against the keys it knows:

  • An unknown key under stoatflow, runtime or logging WARNs once at start with the closest key: stoatflow.lanse: … did you mean stoatflow.lanes?
  • A misspelt section. A top-level section within two edits of stoatflow, runtime or logging that nothing binds WARNs at start, spelled any way the binder reads it (log-ging: binds as logging and does not WARN). A near-miss of stoatflow (stoatflw:) WARNs as soon as your plugins and topology code have run — its keys, the bootstrap servers among them, are ignored, and the start may wait on the default broker. Any other is checked once the application has started, so a section your code binds during the start counts. Any other top-level section is taken to be your application's own and left alone.
  • A dashed Kafka key. Kafka client properties are dotted and reach the client as written. A dashed key whose dotted form is a real client property (group-id) WARNs — stoatflow.kafka.consumer.group-id: did you mean group.id? — and still reaches the client as group-id, where it does nothing. Write Kafka keys dotted (group.id, auto.offset.reset).
  • An unknown variable WARNs as described above.

Set stoatflow.config.strict: true (or STOATFLOW_CONFIG_STRICT=true) to fail the start on an unknown key or a dashed Kafka key instead of warning. It defaults to false. An unknown variable and a misspelt section always stay warnings.

Programmatic overrides

YAML and environment variables cover everything that can be expressed as a string, a number, or a class name. Things that can't — live serde instances, exception-handler objects, callbacks — are configured in code through the streamsConfigOverrides block on the runtime builder. These overrides are applied last, taking precedence over every YAML and env-var source:

val runtime = StoatFlowRuntime.fromConfig(
    topologyBuilder = { buildTopology(it) },
    configure = {
        streamsConfigOverrides {
            defaultKeySerde(Serdes.String())
            defaultValueSerde(Serdes.String())
        }
    },
)
runtime.start()
runtime.awaitTermination()

streamsConfigOverrides exposes the same StreamsConfig.Builder the YAML mapping populates — so anything you can set in YAML you can also set here, and your code wins. Reserve it for the non-serializable types and for values you'd rather compute at runtime than declare statically.

Class-name configuration in YAML

Some non-serializable types have a middle ground: if the class has a no-arg constructor, you can name it in YAML as a fully qualified class name and the runtime instantiates it for you. These are applied above the YAML defaults but below streamsConfigOverrides:

stoatflow:
  default-key-serde: org.apache.kafka.common.serialization.Serdes$StringSerde
  deserialization-exception-handler: io.stoatflow.core.exception.LogAndContinueDeserializationExceptionHandler

The supported class-name keys are default-key-serde, default-value-serde, deserialization-exception-handler, production-exception-handler, processing-exception-handler, and rocks-db-config-setter. Anything requiring a constructor argument must go through streamsConfigOverrides instead.

Inspecting the merged result

The runtime exposes the fully merged, masked configuration at the /config HTTP endpoint — useful for confirming that an env-var override or overlay file actually landed where you expected. Sensitive values (passwords, secrets, tokens, anything from ${secret:…}) are masked in the output, and the sections your application binds through the runtime's configuration appear beside StoatFlow's:

curl -s localhost:8080/config

See the REST API for the full endpoint reference.

Next steps