You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've been talking to @WhitWaldo on Discord about being able to use activities with a scoped lifetime. The root of this for me was a library I'm using is trying to get the HttpContext using IHttpContextAccessor and the context is null.
However, I think for this change to work fully I think we'd have to change the way activities are registered. Currently it's adding an activity to the durable task registry using a factory function. The function we pass in calls ActivatorUtilities.CreateInstance to create the instance of the activity. It looks like the factory is used so that the activity can be wrapped with the ActivityWrapper. I think instead the activity could be registered with DI with the correct scope and then use ActivatorUtilities.GetService in the factory. It'd mean passing the scope into the WorkflowRuntimeOptions as well.
I'm not sure if there would be any repercussions to doing this.
The text was updated successfully, but these errors were encountered:
I've been talking to @WhitWaldo on Discord about being able to use activities with a scoped lifetime. The root of this for me was a library I'm using is trying to get the
HttpContext
usingIHttpContextAccessor
and the context is null.This led to this PR: #1408
However, I think for this change to work fully I think we'd have to change the way activities are registered. Currently it's adding an activity to the durable task registry using a factory function. The function we pass in calls
ActivatorUtilities.CreateInstance
to create the instance of the activity. It looks like the factory is used so that the activity can be wrapped with theActivityWrapper
. I think instead the activity could be registered with DI with the correct scope and then useActivatorUtilities.GetService
in the factory. It'd mean passing the scope into the WorkflowRuntimeOptions as well.I'm not sure if there would be any repercussions to doing this.
The text was updated successfully, but these errors were encountered: