Skip to content
New issue

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

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

Already on GitHub? # to your account

Re-spawning failed actors #40

Open
bobkocisko opened this issue Jul 28, 2020 · 4 comments
Open

Re-spawning failed actors #40

bobkocisko opened this issue Jul 28, 2020 · 4 comments

Comments

@bobkocisko
Copy link

Is there a recommended pattern to concisely re-spawn failed actors? The dissertation suggests potential tools to use to notice dead actors like a retraction of an advertisement but it's unclear to me how to retry the failed operation in those cases without code duplication (especially in the case of something like during/spawn)

@howell
Copy link
Collaborator

howell commented Jul 31, 2020

There is a supervise form and a small example of its use here.

Supervision could be integrated more tightly with during/spawn; as is, you can use the optional #:on-crash argument to respond/restart the actor. (This option is actually even lightly documented!)

@bobkocisko
Copy link
Author

How would one re-spawn the same actor when it dies using during/spawn with #:on-crash? I see the optional argument but I'm not sure how to use that to cause the previously-defined spawn to re-execute itself.

@howell
Copy link
Collaborator

howell commented Aug 11, 2020

You would have the #:on-crash spawn an actor with the same behavior. To avoid duplicating the code, you'd probably need to lift it out to a function, as in:

(assertion-struct example (x y))
(spawn
  (define (actor-body x y)
    ... endpoints in here ...)
  (during/spawn (example $x $y)
    #:on-crash (spawn (actor-body x y))
    (actor-body x y))))

It looks like this could be pretty straightforward to add as a macro if it seems useful enough.

@bobkocisko
Copy link
Author

Ok nice, thanks! I wasn't sure if the lexical context was important with these clauses. Good to know that the actions can be pulled out into their own function. I agree that a macro would be nice!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants