Skip to content

Commit 8f07325

Browse files
committed
more api stuff
1 parent 1f1e3c8 commit 8f07325

File tree

3 files changed

+26
-30
lines changed

3 files changed

+26
-30
lines changed

Sources/Temporal/Bridge/BridgeClient+Context.swift

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,13 @@ extension BridgeClient {
1919
let queue: WorkerClientQueue<[UInt8]>
2020
// Capture the `unary` gRPC method from `AnyUInt8GRPCClient` so that we avoid generics (C-closures can't capture generics)
2121
let unaryGrpcRequest: UnaryCall<UInt8ArraySerializer, UInt8ArrayDeserializer>
22-
let clientName: String = TemporalWorker.Configuration.workerClientName
23-
let clientVersion: String = TemporalWorker.Configuration.workerClientVersion
24-
let apiKey: String?
2522

23+
// NOTE: Headers (client-name, client-version, temporal-namespace, authorization/api-key)
24+
// are ALL handled by the Rust core SDK. We return an empty Metadata here and let
25+
// the Rust core's headers come through via the request_headers in the grpcCallback.
26+
// This avoids duplicate header definitions and ensures consistency with other language SDKs.
2627
var metadata: Metadata {
27-
var metadata: Metadata = [:]
28-
metadata.addString(self.clientName, forKey: "client-name")
29-
metadata.addString(self.clientVersion, forKey: "client-version")
30-
31-
// Add API key authentication if provided
32-
if let apiKey = self.apiKey {
33-
metadata.addString("Bearer \(apiKey)", forKey: "authorization")
34-
}
35-
36-
return metadata
28+
return [:]
3729
}
3830

3931
init(
@@ -43,7 +35,7 @@ extension BridgeClient {
4335
) {
4436
self.queue = queue
4537
self.unaryGrpcRequest = unaryGrpcRequest
46-
self.apiKey = apiKey
38+
// apiKey is passed to Rust core via TemporalWorker.Configuration, not used here
4739
}
4840
}
4941
}

Sources/Temporal/Bridge/BridgeClient.swift

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -265,23 +265,26 @@ package struct BridgeClient: ~Copyable, Sendable {
265265
// has to be a valid URL, otherwise input validation fails
266266
try "https://dummy.temporal.com".withByteArrayRef { dummy_target_url in
267267
try "".withByteArrayRef { empty_string in
268-
let options = TemporalCoreClientOptions(
269-
target_url: dummy_target_url, // Dummy URL as gRPC connection is handled by Swift
270-
client_name: client_name,
271-
client_version: client_version,
272-
metadata: empty_string,
273-
api_key: empty_string,
274-
identity: identityBytes,
275-
tls_options: nil, // Empty TLS config as auth is handled by Swift
276-
retry_options: nil, // Default is picked when passing `nil`
277-
keep_alive_options: nil, // Default is picked when passing `nil`, HTTP2 gRPC keep alive enabled.
278-
http_connect_proxy_options: nil,
279-
grpc_override_callback: grpcCallback,
280-
grpc_override_callback_user_data: grpcCallbackUserDataPointer
281-
)
268+
// Pass API key to Rust core if provided
269+
try (configuration.apiKey ?? "").withByteArrayRef { api_key_bytes in
270+
let options = TemporalCoreClientOptions(
271+
target_url: dummy_target_url, // Dummy URL as gRPC connection is handled by Swift
272+
client_name: client_name,
273+
client_version: client_version,
274+
metadata: empty_string,
275+
api_key: api_key_bytes, // Now passes the actual API key to Rust core
276+
identity: identityBytes,
277+
tls_options: nil, // Empty TLS config as auth is handled by Swift
278+
retry_options: nil, // Default is picked when passing `nil`
279+
keep_alive_options: nil, // Default is picked when passing `nil`, HTTP2 gRPC keep alive enabled.
280+
http_connect_proxy_options: nil,
281+
grpc_override_callback: grpcCallback,
282+
grpc_override_callback_user_data: grpcCallbackUserDataPointer
283+
)
282284

283-
return try withUnsafePointer(to: options) { unsafe_options in
284-
try body(unsafe_options)
285+
return try withUnsafePointer(to: options) { unsafe_options in
286+
try body(unsafe_options)
287+
}
285288
}
286289
}
287290
}

Sources/Temporal/Client/TemporalClient.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public final class TemporalClient: Sendable {
104104
var metadata: GRPCCore.Metadata = [:]
105105
metadata.addString(configuration.clientName, forKey: "client-name")
106106
metadata.addString(configuration.clientVersion, forKey: "client-version")
107+
metadata.addString(configuration.namespace, forKey: "temporal-namespace")
107108

108109
// Add API key authentication if provided
109110
if let apiKey = configuration.apiKey {

0 commit comments

Comments
 (0)