with one click
configure-expression
// Use when: editing libatapp enable_expression config fields, environment-variable expansion syntax, YAML/INI/env loading, or atapp_conf.proto config metadata.
// Use when: editing libatapp enable_expression config fields, environment-variable expansion syntax, YAML/INI/env loading, or atapp_conf.proto config metadata.
Use when: auditing or optimizing AI agent prompts, bridge files, skills, SKILL.md metadata, and cross-tool compatibility.
Use when: configuring or building libatapp with CMake, changing shared/static builds, or adjusting build type options.
Use when: working on libatapp etcd integration, service discovery sets, topology management, keepalive actors, watchers, node selection, or etcd_module.
Use when: writing libatapp modules, connectors, endpoint management, connection handles, message routing, suspend_stop logic, or multi-node tests.
Use when: running or writing libatapp unit tests, filtering private test cases, using multi-node/debug-time patterns, testing etcd, or fixing Windows DLL/PATH startup issues.
| name | configure-expression |
| description | Use when: editing libatapp enable_expression config fields, environment-variable expansion syntax, YAML/INI/env loading, or atapp_conf.proto config metadata. |
Protobuf fields annotated with enable_expression: true in the atapp_configure_meta extension
support environment-variable expression expansion when configuration is loaded from YAML, INI (.conf),
or environment-variable files.
| Syntax | Description |
|---|---|
$VAR | Bare variable — POSIX names only ([A-Za-z_][A-Za-z0-9_]*) |
${VAR} | Braced variable — any characters allowed, including ., -, / (k8s labels) |
${VAR:-default} | If VAR is unset or empty, expand to default |
${VAR:+word} | If VAR is set and non-empty, expand to word; otherwise empty string |
\$ | Literal dollar sign (escape) |
| Nested | ${OUTER_${INNER}}, ${VAR:-${OTHER:-fallback}} — arbitrary nesting |
$VAR vs Braced ${VAR}$VAR stops at the first character that is not [A-Za-z0-9_].
Characters such as ., -, / are not consumed, so $app.name resolves only $app.${VAR} accepts any characters up to the matching }, which makes it suitable for
Kubernetes-style labels like ${app.kubernetes.io/name}.Follows bash semantics:
${VAR:-default} — triggers when VAR is empty or unset (empty string counts as unset).${VAR:+word} — triggers only when VAR is non-empty.default and word can themselves contain nested expressions: ${A:-${B:-fallback}}.The extension is defined in atapp_conf.proto:
message atapp_configure_meta {
// ...
bool enable_expression = 6; // Enable expression expansion for this field
}
Usage example:
message atapp_metadata {
map<string, string> label = 21
[(atframework.atapp.protocol.CONFIGURE) = { enable_expression: true }];
}
For map fields, both key and value are expanded when the parent field has enable_expression: true.
Expression expansion is applied in all three config-loading paths:
.conf) — values are expanded after parsing INI key-value pairs.env.txt files are expandedThe loader checks enable_expression on the field's FieldOptions extension (or the parent map
field for map entry sub-fields). Only fields that opt in are expanded.
#include <atframe/atapp_conf.h>
// Expand environment expressions in an arbitrary string.
// Useful outside of config loading (e.g. in custom modules).
std::string result = atframework::atapp::expand_environment_expression("Hello ${USER:-world}");
Environment variables are read via atfw::util::file_system::getenv() (not std::getenv()).
# app.yaml
atapp:
metadata:
label:
app.kubernetes.io/name: "${APP_NAME:-my-service}"
service_subset: "${SUBSET:-${ZONE:-default}}"
bus:
listen:
- "ipv4://0.0.0.0:${LISTEN_PORT:-12345}"
[atapp.metadata.label]
app.kubernetes.io/name=${APP_NAME:-my-service}
service_subset=${SUBSET:-${ZONE:-default}}
[atapp.bus]
listen=ipv4://0.0.0.0:${LISTEN_PORT:-12345}