@@ -153,6 +153,7 @@ export interface RPCImplOptions {
153
153
client : grpc . Client ;
154
154
callContextStorage : AsyncLocalStorage < CallContext > ;
155
155
interceptors ?: grpc . Interceptor [ ] ;
156
+ staticMetadata : Metadata ;
156
157
}
157
158
158
159
export interface ConnectionCtorOptions {
@@ -221,27 +222,29 @@ export class Connection {
221
222
optionsWithDefaults . channelArgs
222
223
) ;
223
224
const callContextStorage = new AsyncLocalStorage < CallContext > ( ) ;
224
- callContextStorage . enterWith ( { metadata : optionsWithDefaults . metadata } ) ;
225
225
226
226
const workflowRpcImpl = this . generateRPCImplementation ( {
227
227
serviceName : 'temporal.api.workflowservice.v1.WorkflowService' ,
228
228
client,
229
229
callContextStorage,
230
230
interceptors : optionsWithDefaults ?. interceptors ,
231
+ staticMetadata : optionsWithDefaults . metadata ,
231
232
} ) ;
232
233
const workflowService = WorkflowService . create ( workflowRpcImpl , false , false ) ;
233
234
const operatorRpcImpl = this . generateRPCImplementation ( {
234
235
serviceName : 'temporal.api.operatorservice.v1.OperatorService' ,
235
236
client,
236
237
callContextStorage,
237
238
interceptors : optionsWithDefaults ?. interceptors ,
239
+ staticMetadata : optionsWithDefaults . metadata ,
238
240
} ) ;
239
241
const operatorService = OperatorService . create ( operatorRpcImpl , false , false ) ;
240
242
const healthRpcImpl = this . generateRPCImplementation ( {
241
243
serviceName : 'grpc.health.v1.Health' ,
242
244
client,
243
245
callContextStorage,
244
246
interceptors : optionsWithDefaults ?. interceptors ,
247
+ staticMetadata : optionsWithDefaults . metadata ,
245
248
} ) ;
246
249
const healthService = HealthService . create ( healthRpcImpl , false , false ) ;
247
250
@@ -329,10 +332,14 @@ export class Connection {
329
332
client,
330
333
callContextStorage,
331
334
interceptors,
335
+ staticMetadata,
332
336
} : RPCImplOptions ) : RPCImpl {
333
337
return ( method : { name : string } , requestData : any , callback : grpc . requestCallback < any > ) => {
334
338
const metadataContainer = new grpc . Metadata ( ) ;
335
339
const { metadata, deadline } = callContextStorage . getStore ( ) ?? { } ;
340
+ for ( const [ k , v ] of Object . entries ( staticMetadata ) ) {
341
+ metadataContainer . set ( k , v ) ;
342
+ }
336
343
if ( metadata != null ) {
337
344
for ( const [ k , v ] of Object . entries ( metadata ) ) {
338
345
metadataContainer . set ( k , v ) ;
0 commit comments