Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

preserve reentrant header used for actors ... through the service invocation process #964

Open
aktxyz opened this issue Sep 30, 2022 · 6 comments

Comments

@aktxyz
Copy link

aktxyz commented Sep 30, 2022

In the dapr doc info, they show some reentrant actor scenarios. It looks like the dapr dotnet sdk automatically creates and passes the reentrant header id ... so as long as you follow the basic scenarios described in the docs it works fine.

ActorA -> ActorA
ActorA -> ActorB -> ActorA

https://docs.dapr.io/developing-applications/building-blocks/actors/actor-reentrancy/

I am wanting a do a slightly different scenario that includes a service invocation in the process.

ActorA -> invoke some service -> ActorA

This is currently not working because the reentrant header is not automatically preserved during a service invocation.

@aktxyz
Copy link
Author

aktxyz commented Sep 30, 2022

I actually have this working with out too many changes ... that said I am sure the implementation is not up proper standards, missing scenarios, and certainly no tests ... is it worth submitting a PR or pointing to a fork to have folks take a look?

@aktxyz
Copy link
Author

aktxyz commented Sep 30, 2022

basically tuck away the reentrant header id here (before service invocation)

// aktxyz tuck away reentrant header id before service invocation
if (Dapr.Actors.ActorReentrancyContextAccessor.ReentrancyContext != null)
{
    request.Headers.TryAddWithoutValidation(Constants.ReentrancyRequestHeaderName, Dapr.Actors.ActorReentrancyContextAccessor.ReentrancyContext);
}

and then on the receiving end, pluck out the reentrant header id here

// aktxyz pluck out the reentrant header id after service service invocation
if (httpContext.Request.Headers.ContainsKey(Dapr.Client.Constants.ReentrancyRequestHeaderName))
{
    var daprReentrancyHeader = httpContext.Request.Headers[Dapr.Client.Constants.ReentrancyRequestHeaderName];
    Dapr.Actors.ActorReentrancyContextAccessor.ReentrancyContext = daprReentrancyHeader;
}

This seems to work fine ... so good enough to keep working ... would love to see support for this added in a proper way sometime in the future.

@aktxyz
Copy link
Author

aktxyz commented Oct 13, 2024

Does anyone on the DAPR team have any thoughts on this ... I think maintaining the reentrant header id across service invocations is a good thing !

@WhitWaldo
Copy link
Contributor

I understand that this functionality is technical feasible. However, it would be really helpful if you could provide more details about the specific scenario where this shortcoming is blocking you and your project. This information would strengthen the case for addressing this issue, rather than it being seen as an interesting aspect of an otherwise incomplete but usable feature.

@aktxyz
Copy link
Author

aktxyz commented Oct 14, 2024

basically I have a case where I do something like this ...

ActorA -> invoke some service -> ActorA

  • ActorA receives a request
  • ActorA pubs out an async message (service invoke), which is picked up by multiple services listening for this message type
  • when each service completes it's task, it sends results back to ActorA via a message

so basically

ActorA -> invoke some services (reentrant ID lost here) -> ActorA

@WhitWaldo
Copy link
Contributor

Why do you need re-entrancy for this scenario? Why not simply call the actor anew with the message results?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants