Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions client/src/workflow_handle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,7 @@ where
o => Err(anyhow!(
"Server returned an event that didn't match the CloseEvent filter. \
This is either a server bug or a new event the SDK does not understand. \
Event details: {:?}",
o
Event details: {o:?}"
)),
};
}
Expand Down
42 changes: 31 additions & 11 deletions core-api/src/envconfig.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1592,12 +1592,38 @@ address = "some-address"

#[test]
fn test_load_client_config_profile_from_system_env() {
// Set up system env vars. These tests can't be run in parallel.
unsafe {
std::env::set_var("TEMPORAL_ADDRESS", "system-address");
std::env::set_var("TEMPORAL_NAMESPACE", "system-namespace");
}
let cargo = std::env::var("CARGO").unwrap_or_else(|_| "cargo".to_string());
let output = std::process::Command::new(cargo)
.arg("test")
.arg("-F")
.arg("envconfig")
.arg("envconfig::tests::test_load_client_config_profile_from_system_env_impl")
.arg("--")
.arg("--exact")
.arg("--ignored")
.env("TEMPORAL_ADDRESS", "system-address")
.env("TEMPORAL_NAMESPACE", "system-namespace")
.output()
.expect("Failed to execute subprocess test");

assert!(
output.status.success(),
"Subprocess test failed:\nstdout: {}\nstderr: {}",
String::from_utf8_lossy(&output.stdout),
String::from_utf8_lossy(&output.stderr),
);
}

#[test]
#[ignore] // Only run when explicitly called
fn test_load_client_config_profile_from_system_env_impl() {
// Check if we're in the right context
if std::env::var("TEMPORAL_ADDRESS").is_err()
|| std::env::var("TEMPORAL_NAMESPACE").is_err()
{
eprintln!("Skipping test - required env vars not set");
return; // Early return instead of panic
}
let options = LoadClientConfigProfileOptions {
disable_file: true, // Don't load from any files
..Default::default()
Expand All @@ -1607,12 +1633,6 @@ address = "some-address"
let profile = load_client_config_profile(options, None).unwrap();
assert_eq!(profile.address.as_ref().unwrap(), "system-address");
assert_eq!(profile.namespace.as_ref().unwrap(), "system-namespace");

// Clean up
unsafe {
std::env::remove_var("TEMPORAL_ADDRESS");
std::env::remove_var("TEMPORAL_NAMESPACE");
}
}

#[test]
Expand Down
2 changes: 2 additions & 0 deletions core-c-bridge/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ prost = { workspace = true }
# cause non-determinism.
rand = "0.9.2"
rand_pcg = "0.9.0"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = "1.47"
tokio-stream = "0.1"
Expand All @@ -38,6 +39,7 @@ features = ["ephemeral-server"]

[dependencies.temporal-sdk-core-api]
path = "../core-api"
features = ["envconfig"]

[dependencies.temporal-sdk-core-protos]
path = "../sdk-core-protos"
Expand Down
61 changes: 61 additions & 0 deletions core-c-bridge/include/temporal-sdk-core-c-bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,53 @@ typedef void (*TemporalCoreClientRpcCallCallback)(void *user_data,
const struct TemporalCoreByteArray *failure_message,
const struct TemporalCoreByteArray *failure_details);

/**
* OrFail result for client config loading operations.
* Either success or fail will be null, but never both.
* If success is not null, it contains JSON-serialized client configuration data.
* If fail is not null, it contains UTF-8 encoded error message.
* The returned ByteArrays must be freed by the caller.
*/
typedef struct TemporalCoreClientEnvConfigOrFail {
const struct TemporalCoreByteArray *success;
const struct TemporalCoreByteArray *fail;
} TemporalCoreClientEnvConfigOrFail;

/**
* Options for loading client configuration.
*/
typedef struct TemporalCoreClientEnvConfigLoadOptions {
struct TemporalCoreByteArrayRef path;
struct TemporalCoreByteArrayRef data;
bool config_file_strict;
struct TemporalCoreByteArrayRef env_vars;
} TemporalCoreClientEnvConfigLoadOptions;

/**
* OrFail result for client config profile loading operations.
* Either success or fail will be null, but never both.
* If success is not null, it contains JSON-serialized client configuration profile data.
* If fail is not null, it contains UTF-8 encoded error message.
* The returned ByteArrays must be freed by the caller.
*/
typedef struct TemporalCoreClientEnvConfigProfileOrFail {
const struct TemporalCoreByteArray *success;
const struct TemporalCoreByteArray *fail;
} TemporalCoreClientEnvConfigProfileOrFail;

/**
* Options for loading a specific client configuration profile.
*/
typedef struct TemporalCoreClientEnvConfigProfileLoadOptions {
struct TemporalCoreByteArrayRef profile;
struct TemporalCoreByteArrayRef path;
struct TemporalCoreByteArrayRef data;
bool disable_file;
bool disable_env;
bool config_file_strict;
struct TemporalCoreByteArrayRef env_vars;
} TemporalCoreClientEnvConfigProfileLoadOptions;

typedef union TemporalCoreMetricAttributeValue {
struct TemporalCoreByteArrayRef string_value;
int64_t int_value;
Expand Down Expand Up @@ -771,6 +818,20 @@ void temporal_core_client_rpc_call(struct TemporalCoreClient *client,
void *user_data,
TemporalCoreClientRpcCallCallback callback);

/**
* Load all client profiles from given sources.
* Returns ClientConfigOrFail with either success JSON or error message.
* The returned ByteArrays must be freed by the caller.
*/
struct TemporalCoreClientEnvConfigOrFail temporal_core_client_env_config_load(const struct TemporalCoreClientEnvConfigLoadOptions *options);

/**
* Load a single client profile from given sources with env overrides.
* Returns ClientConfigProfileOrFail with either success JSON or error message.
* The returned ByteArrays must be freed by the caller.
*/
struct TemporalCoreClientEnvConfigProfileOrFail temporal_core_client_env_config_profile_load(const struct TemporalCoreClientEnvConfigProfileLoadOptions *options);

struct TemporalCoreMetricMeter *temporal_core_metric_meter_new(struct TemporalCoreRuntime *runtime);

void temporal_core_metric_meter_free(struct TemporalCoreMetricMeter *meter);
Expand Down
10 changes: 5 additions & 5 deletions core-c-bridge/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ async fn call_workflow_service(
"UpdateWorkerBuildIdCompatibility" => {
rpc_call!(client, call, update_worker_build_id_compatibility)
}
rpc => Err(anyhow::anyhow!("Unknown RPC call {}", rpc)),
rpc => Err(anyhow::anyhow!("Unknown RPC call {rpc}")),
}
}

Expand Down Expand Up @@ -715,7 +715,7 @@ async fn call_operator_service(
"UpdateNexusEndpoint" => {
rpc_call_on_trait!(client, call, OperatorService, update_nexus_endpoint)
}
rpc => Err(anyhow::anyhow!("Unknown RPC call {}", rpc)),
rpc => Err(anyhow::anyhow!("Unknown RPC call {rpc}")),
}
}

Expand Down Expand Up @@ -785,7 +785,7 @@ async fn call_cloud_service(client: &CoreClient, call: &RpcCallOptions) -> anyho
"GetConnectivityRule" => rpc_call!(client, call, get_connectivity_rule),
"GetConnectivityRules" => rpc_call!(client, call, get_connectivity_rules),
"DeleteConnectivityRule" => rpc_call!(client, call, delete_connectivity_rule),
rpc => Err(anyhow::anyhow!("Unknown RPC call {}", rpc)),
rpc => Err(anyhow::anyhow!("Unknown RPC call {rpc}")),
}
}

Expand All @@ -799,7 +799,7 @@ async fn call_test_service(client: &CoreClient, call: &RpcCallOptions) -> anyhow
"Sleep" => rpc_call!(client, call, sleep),
"UnlockTimeSkippingWithSleep" => rpc_call!(client, call, unlock_time_skipping_with_sleep),
"UnlockTimeSkipping" => rpc_call!(client, call, unlock_time_skipping),
rpc => Err(anyhow::anyhow!("Unknown RPC call {}", rpc)),
rpc => Err(anyhow::anyhow!("Unknown RPC call {rpc}")),
}
}

Expand All @@ -814,7 +814,7 @@ async fn call_health_service(
"Watch" => Err(anyhow::anyhow!(
"Health service Watch method is not implemented in C bridge"
)),
rpc => Err(anyhow::anyhow!("Unknown RPC call {}", rpc)),
rpc => Err(anyhow::anyhow!("Unknown RPC call {rpc}")),
}
}

Expand Down
Loading
Loading