Repository navigation
feat(envconfig): add extension support - #2079
Conversation
|
|
bcf5e9d to
d4d4a6b
Compare
|
I added an additional commit to convert TOML datetimes within envconfig |
|
Converting to a draft just because I don't like having open PRs which pass CI but shouldn't merge, it can be reviewed in draft until core is ready. |
SGTM, I converted the .NET/Ruby ones as well |
Add support for envconfig extensions. These allow separate packages to extend envconfig with their own TOML keys and environment variables by implementing the ClientConfigExtension interface. An extension operates on a config profile as input and outputs a plugin to be attached to the client created from envconfig output. A TOML file with an extension looks as follows: ``` [profile.default.ext.my_extension] some_field = "value" ``` An envconfig consumer specifies a list of extensions to use when loading connection options via ClientConfig.load_client_connect_config(extensions=...). Returned plugins are client plugins set under the "plugins" key of the resulting ClientConnectConfig, so they are applied when the config is passed to Client.connect(**config). For now, extensions are not supported in other contexts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Convert TOML datetimes in profile ext tables the same way as tomllib, instead of passing them through as ISO 8601 strings. Offset datetimes become aware datetimes, local datetimes become naive datetimes, local dates become dates, and local times become times, with fractional seconds truncated to microseconds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d4d4a6b to
4560e3a
Compare
|
(Force push to rebase on the recent sdk-core submodule bump in #2093) |
What was changed
Add support for envconfig extensions. These allow separate packages to extend envconfig with their own TOML keys and environment variables by implementing the
ClientConfigExtensioninterface. An extension operates on a config profile as input and outputs a plugin to be attached to the client created from envconfig output.A TOML file with an extension looks as follows:
An envconfig consumer specifies a list of extensions to use when loading connection options via
ClientConfig.load_client_connect_config(extensions=...). Returned plugins are client plugins set under the "plugins" key of the resultingClientConnectConfig, so they are applied when the config is passed toClient.connect(**config). For now, extensions are not supported in other contexts.Why?
It's useful for external packages to be able to extend the envconfig format without needing to modify the envconfig package itself. The first use-case for this will be integrating with AWS Secrets Manager to specify client secrets via Secrets Manager ID.
Also see the Go implementation in temporalio/sdk-go#2771. Also see the Rust core change in temporalio/sdk-rust#1736.
Checklist
temporal.toml(viaTEMPORAL_CONFIG_FILE) with an[profile.default.ext.e2e]table, using real process env vars (TEMPORAL_NAMESPACE,TEMPORAL_EXT_E2E_SUFFIX). An extension passed toClientConfig.load_client_connect_configread its TOML table and env var and returned a plugin. The program confirmed that the extension saw the env-overridden profile, and that the returned config had the expected namespace and target host and exactly one plugin carrying the expected values.The associated in-repo docs are updated. I don't think we need other public docs for now, as right now this is primarily just an implementation detail for the Lambda worker integration with Secrets Manager.