Repository navigation
feat(envconfig): add extension support - #1736
Conversation
Add support for envconfig extensions. These allow separate packages to extend envconfig with their own TOML keys and environment variables by implementing the ClientConfigExtension trait. 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" ``` Core: config profiles expose the raw TOML tables under profile.<name>.ext, keyed by extension name. Rust SDK: behind the experimental feature, an envconfig consumer specifies a list of extensions to use when loading client options via ClientOptions::load_from_config_with_extensions(). Returned plugins are registered on the returned ClientOptions. For now, extensions are not supported in other contexts. C bridge: the profile JSON includes ext, so core-based SDKs can implement extensions on top of it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
a9626f6 to
3fd4b5b
Compare
|
(Slight update: decided to add a |
It's long and probably unnecessary.
THardy98
left a comment
There was a problem hiding this comment.
LGTM.
One requested change:
Could we explicitly document that callers should pass these returned options to Client::connect? The existing envconfig quick-start uses Connection::connect followed by Client::new, which skips connection plugin hooks.
This is a gotcha that needs to be explicitly documented
Ah, good catch. I added a note to the file-level docstring/snippet and also the docstring for |
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 ClientConfigExtension trait. 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:
Core: config profiles expose the raw TOML tables under profile..ext, keyed by extension name.
Rust SDK: behind the experimental feature, an envconfig consumer specifies a list of extensions to use when loading client options via ClientOptions::load_from_config_with_extensions(). Returned plugins are registered on the returned ClientOptions. For now, extensions are not supported in other contexts.
C bridge: the profile JSON includes ext, so core-based SDKs can implement extensions on top of it.
Why?
It's useful for external modules to be able to extend the envconfig format without needing to modify the envconfig module itself. The first use-case for this will be integrating with AWS Secrets Manager to specify client secrets via Secrets Manager ID.
Since envconfig in Python, .NET, and Ruby are based on the Rust core through the C bridge, this change is a necessary prerequisite for implementing envconfig extensions in those languages. Those changes won't be able to proceed without a submodule update.
Also see the Go implementation in temporalio/sdk-go#2771
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 toClientOptions::load_from_config_with_extensionsread 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 options had the expected namespace and target 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.