Skip to content

Akka.Actors: schedule one-off tasks with IWithTimers #7630

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

Open
Aaronontheweb opened this issue May 9, 2025 · 0 comments
Open

Akka.Actors: schedule one-off tasks with IWithTimers #7630

Aaronontheweb opened this issue May 9, 2025 · 0 comments

Comments

@Aaronontheweb
Copy link
Member

Is your feature request related to a problem? Please describe.

One of the things that has made it difficult for us to consistently resolve AK1004 everywhere inside our own code-base is the use of unique timer keys. There are many cases where you do not want a unique timer key for a recurring task - the change I just made to Akka.IO is a good example of one:

case SocketError.WouldBlock:
// transient – short back‑off then retry
saea.AcceptSocket = null;
Context.System.Scheduler.ScheduleTellOnce(TimeSpan.FromMilliseconds(10), Self,
new RetryAccept(saea), ActorRefs.NoSender);
break;

If I have n socket operations that all failed, I need to reschedule each one independently - today that will require me to generate a key-per-socket if I want to use IWithTimers. If I just use the old scheduler directly instead, I no longer have that problem.

Describe the solution you'd like

It would be great if we could create a "keyless" timer for single-shot timers only for this type of task: a specific, self-describing unit of work that needs to be delayed until some point in the future. We can still cancel this unit of work when the actor shuts down (because: key is synthetic and stored internally

Describe alternatives you've considered

Just go back to using the scheduler, which is what we're doing currently, but this also requires suppressing AK1004 warnings.

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

1 participant