Only isolate state when using reentrancy (#723)

Non-reentrant actors can utilize their state manager's cache
for repeated calls. They should still be able to do this unless
using reentrancy.

Co-authored-by: Ryan Nowak <nowakra@gmail.com>
This commit is contained in:
halspang 2021-07-22 22:28:36 +00:00 committed by GitHub
parent 56ac2431b0
commit 5e544a687a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -339,10 +339,13 @@ namespace Dapr.Actors.Runtime
T retval;
try
{
// Set the state context of the request, if possible.
if (state.Actor.StateManager is IActorContextualState contextualStateManager)
// Set the state context of the request, if required and possible.
if (ActorReentrancyContextAccessor.ReentrancyContext != null)
{
await contextualStateManager.SetStateContext(Guid.NewGuid().ToString());
if (state.Actor.StateManager is IActorContextualState contextualStateManager)
{
await contextualStateManager.SetStateContext(Guid.NewGuid().ToString());
}
}
// invoke the function of the actor