I have the following case…
Assuming an activity in a workflow expect a jwt as parameter to make an http call… what is the best aceptable way to solve this case?
I’m trying to avoid if possible passing the value in the signalWorkflow payload… I was expecting to use context for this, however, I notice the context is only set when a workflow is created, adding the value to ctx when calling the signal api does not work.
Any ideas or practices for solve similar cases? maybe just using the payload is the only available option, right?
Primary way would be to pass it via parameters, another way could be to set the token when you register your activity with the worker, see sample here.
You could encrypt the value if you wanted with a data converter, see sample here.
Can you explain your use case with passing it via signals, does your token change / needs to be updated via the signal payload?
Hey! thank you for answer.
The use case I have is a long running workflow, which one of the activities, is meant to call a 3rd party service, so we need a way to pass different auth mechanism like jwt, api keys, etc.
So the problem I have with the methods you shared is they seem to require the information to be available when the workflow starts, and I cannot provide it at that time but later in the process.
Said it this, is still the recommended to use the signal parameters?
require the information to be available when the workflow starts, and I cannot provide it at that time but later in the process
Activity code is your code so you could retrieve needed info (maybe based on user id and the needed auth) at runtime without having to rely on signals only.
Another idea would be to use interceptors / headers to set/retrieve this information.
oh interesting!! I will check the interceptors, I was not aware of it!!
Thank you so much!
@kapiandy I am trying to do something similar - where I’d like to pass values in the context.Context via a Signal.
Did you come up with a solution for this?
hey Kevin, no i havent, but i think my problem is i made a wrong call in the implementation which is causing lose the context along the way… i hacked this a little but creating a facade on top of the signal where i deserialize/serialize the values a need an pass em with the signal using interceptors…
To be noted, I’m not exposing the sdk directly to developers, i have my own implementation which use the sdk, this allow me to hack this challenges along the way.