Skip to content

feat: Expose envconfig functionality through C bridge#986

Merged
THardy98 merged 16 commits intomasterfrom
expose_envconfig_c_bridge
Sep 19, 2025
Merged

feat: Expose envconfig functionality through C bridge#986
THardy98 merged 16 commits intomasterfrom
expose_envconfig_c_bridge

Conversation

@THardy98
Copy link
Copy Markdown
Contributor

What was changed

C bridge code for .NET env config

  1. Part of [Feature Request] Environment Configuration sdk-dotnet#490

  2. How was this tested:
    Integration tests lang-side

  3. Any docs updates needed?
    No

@THardy98 THardy98 force-pushed the expose_envconfig_c_bridge branch from 240b196 to 9a9cbe7 Compare August 25, 2025 18:46
@THardy98 THardy98 marked this pull request as ready for review August 25, 2025 20:12
@THardy98 THardy98 requested a review from a team as a code owner August 25, 2025 20:12
Copy link
Copy Markdown
Contributor

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor suggestions. Also, can we submit use of this (which I am guessing is at temporalio/sdk-dotnet#509) for PR review before merging this just to make sure we're good there from a review POV? We can basically merge both at once when both approved (obviously this first and submodule update over there).

Comment thread core-c-bridge/src/envconfig.rs Outdated
Comment thread core-c-bridge/src/envconfig.rs Outdated
Comment thread core-c-bridge/src/envconfig.rs Outdated
- Replace multiple function parameters with ClientConfigLoadOptions and
  ClientConfigProfileLoadOptions structs
- Remove async callbacks and change functions
- Improve documentation to clarify byte array formats
- Add ClientConfigOrFail and ClientConfigProfileOrFail result structs
@THardy98 THardy98 force-pushed the expose_envconfig_c_bridge branch from 9a9cbe7 to 614c72e Compare September 15, 2025 18:23
@cretz
Copy link
Copy Markdown
Contributor

cretz commented Sep 15, 2025

Let me know if/when the PR is ready for re-review (if you want, you can respond to comments to make it easier to know which are agreed with and/or handled)

@THardy98
Copy link
Copy Markdown
Contributor Author

Let me know if/when the PR is ready for re-review (if you want, you can respond to comments to make it easier to know which are agreed with and/or handled)

RFR, resolved the above comments

Comment thread core-c-bridge/include/temporal-sdk-core-c-bridge.h Outdated
Comment thread core-c-bridge/src/lib.rs Outdated
Comment thread core-c-bridge/src/envconfig.rs Outdated
@THardy98 THardy98 requested a review from cretz September 17, 2025 14:29
Copy link
Copy Markdown
Member

@Sushisource Sushisource left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me but I'd like to fix that env var test so it doesn't interfere with others

Comment thread core-api/src/envconfig.rs Outdated
Comment on lines +1595 to +1597
// WARNING: This test modifies system environment variables which can cause
// test pollution if tests run in parallel.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we should not do that. I assume you ran into this and it caused a problem somehow? I missed this one when it first when in.

The move here is to spawn off this test into a new process, and you can set the env vars for just that process. The test can early-return unless some special env var is set that lets it know it's been spawned off.

Copy link
Copy Markdown
Contributor Author

@THardy98 THardy98 Sep 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm the change I made to this test is working locally, but I guess CI may have more restrictions around setting env variables, given that the thread panicked:

thread 'envconfig::tests::test_load_client_config_profile_from
  _system_env_impl' panicked at 
  core-api/src/envconfig.rs:1627:45

the alternative I can think of is to revert the test change and just run it serially

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't realize we run ignored tests in CI, this is panicking because env vars aren't set. Added conditional to skip if env vars aren't set

Comment thread core-c-bridge/src/envconfig.rs Outdated
Copy link
Copy Markdown
Contributor

@cretz cretz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, only the pedantic naming thing (and +1 on not having a side-effecting test)

* If fail is not null, it contains UTF-8 encoded error message.
* The returned ByteArrays must be freed by the caller.
*/
typedef struct TemporalCoreClientConfigOrFail {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be pedantic here and sorry I didn't read close enough earlier, but this is not clear it's env config, it makes it seem like it's generic config. Can we change the 4 struct names here to have Env before the word Config? Also can we change the two function names to change config to env_config?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not at all - renamed all structs to have Env before Config. Renamed the function names config -> env_config

…fig test using system env vars in separate process
@THardy98 THardy98 force-pushed the expose_envconfig_c_bridge branch from 9ff4dc4 to 024df91 Compare September 19, 2025 06:27
@THardy98 THardy98 force-pushed the expose_envconfig_c_bridge branch from 84d7d3c to 543a067 Compare September 19, 2025 16:34
@THardy98 THardy98 force-pushed the expose_envconfig_c_bridge branch from ce144c6 to de26121 Compare September 19, 2025 18:27
@THardy98 THardy98 merged commit 079d1f3 into master Sep 19, 2025
19 checks passed
@THardy98 THardy98 deleted the expose_envconfig_c_bridge branch September 19, 2025 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants