sdk-core
sdk-core copied to clipboard
[Feature Request] Dynamic HTTP headers
Currently it's only possible to configure static HTTP headers on the Client, we need to add a way to specify dynamic ones. A typical use case for this would be to refresh an auth token and users should not be required to recreate their workers for that.
I think an Option<Fn(&mut HashMap<String, String>)> is reasonable at the client level (or tonic::metadata::MetadataMap or http::header::HeaderMap or whatever). But I wonder if we want to discuss general purpose gRPC interception lang callbacks at this time or save that discussion for later. I am thinking later since this is per call option and doesn't need to use gRPC interceptors from a Tonic POV.
We will have to add general interceptors at some point but I don't think it has to be tied to dynamic headers. At some point soon we should also consider exposing the deadline for individual calls too.
We already have dynamic headers, keeping this open for per request headers and deadline
Is there any news on this? we need to change a header per request to include a security token. In java we can do it, but I'm not pretty sure that we can do it in JS SDK
@jrpedrianes for JS clients, you can set per request headers and deadline. This issue should be closed. See the api reference here: https://typescript.temporal.io/api/classes/client.Connection#withmetadata
Thanks, @bergundy.
At worker level I see that I can use https://typescript.temporal.io/api/classes/worker.NativeConnection#setmetadata, the method signature is not the same, but it seems that I can call it as many times as I need, in my case to update a security token that a worker needs to send to the temporal server, this token expires, so I need to update it frequently.