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

Add ReceiveAsync feature to Akka.TestKit TestActorRef #6281

Merged

Conversation

Arkatufus
Copy link
Contributor

@Arkatufus Arkatufus commented Nov 30, 2022

Fixes #6265

Changes

  • Add ReceiveAsync feature to Akka.TestKit TestActorRef
  • Add IAsyncResultInterceptor interface to tap directly into ReceiveAsync execution result

@Aaronontheweb Aaronontheweb added the akka-testkit Akka.NET Testkit issues label Nov 30, 2022
@Aaronontheweb Aaronontheweb added this to the 1.5.0 milestone Nov 30, 2022
Copy link
Member

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but not sure if we need an API approval here

context.CheckReceiveTimeout();
}
else
{
context.Self.AsInstanceOf<IInternalActorRef>().SendSystemMessage(new ActorTaskSchedulerMessage(exception, actorScheduler.CurrentMessage));
}

// Used by TestActorRef to intercept async execution result
if(actorScheduler is IAsyncResultInterceptor interceptor)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer not to do this on the TaskScheduler that all actors use, but I don't really see a way around it - this is probably the best call we can make in the short run, without redesigining the mailbox system to use Task.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, other alternatives would require a more radical change to implement, this is the shortest solution I can find without scrambling codes all over the place

/// </summary>
/// <param name="message">The message.</param>
/// <param name="sender">The sender.</param>
public Task ReceiveAsync(object message, IActorRef sender = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

won't this require API approvals @Arkatufus ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't look like it, at least not locally

@Aaronontheweb Aaronontheweb enabled auto-merge (squash) November 30, 2022 22:15
@Aaronontheweb Aaronontheweb merged commit 5605d83 into akkadotnet:dev Dec 1, 2022
@Aaronontheweb
Copy link
Member

Yep, did not require API approval

Arkatufus added a commit to Arkatufus/akka.net that referenced this pull request Dec 1, 2022
Aaronontheweb pushed a commit that referenced this pull request Dec 2, 2022
* Add ReceiveAsync feature to Akka.TestKit TestActorRef (#6281)

Co-authored-by: Aaron Stannard <[email protected]>
(cherry picked from commit 5605d83)

* Post-merge fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
akka-testkit Akka.NET Testkit issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TestActorRef can not catch exceptions on asynchronous methods
2 participants