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

Supervisor API #22

Open
goodboy opened this issue Jul 28, 2018 · 4 comments
Open

Supervisor API #22

goodboy opened this issue Jul 28, 2018 · 4 comments
Labels

Comments

@goodboy
Copy link
Owner

goodboy commented Jul 28, 2018

I want to start design discussion on how to approach erlang-like supervisors including restart strategies and how this will interplay with a service discovery system and possibly real-time code replacement.

Some questions/comments I have:

  • what's the (semantic) difference between a nursery and a supervisor?

  • an explicit distinction should be made between a MainProcess supervisor and the arbiter actor

    • the Arbiter is per-host and is part of service discovery between hosts
  • how do we best implement a distributed supervisor (one that spawns actors over multiple hosts)?

    • does it simply send the spawn request to the appropriate arbiter who will then create or use a host-local nursery?
    • what happens when all actors on the remote host go down but a remote actor is still using a remotely spawned actor in that process cluster?
  • what does a distributed process supervisor API look like?

    • how does this interact with the arbiter and service discovery system?
  • how does an orchestration layer build on all this?

  • here's erlang's supervisor behaviors

Much more to come...

@goodboy goodboy added enhancement New feature or request question Further information is requested labels Jul 28, 2018
@goodboy goodboy added discussion help wanted Extra attention is needed and removed question Further information is requested labels Oct 23, 2020
@goodboy
Copy link
Owner Author

goodboy commented Oct 23, 2020

Worth a read is elixir's page on supervisors and dynamic supervisors.

@goodboy goodboy changed the title Supervisors - what are they good for? Supervisor API Mar 4, 2021
@goodboy goodboy added the api label Mar 4, 2021
@goodboy
Copy link
Owner Author

goodboy commented Mar 4, 2021

We had a brief discussion a while back slightly in regard to #190 (this comment) related apis.

For supervisors I actually think we can make quite a nice api by just offering composed async context managers:

async with tractor.open_nursery() as n:

    async with tractor.supervise.one_for_one(n) as one_for_one_nursery:
        
        await one_for_one_nursery.run_in_actor(blah)

In 3.10 parentheses syntax this becomes:

async with (
    tractor.open_nursery() as n,
    tractor.supervise.one_for_one(n) as one_for_one_nursery,
):        
        await one_for_one_nursery.run_in_actor(blah)
        

This has the benefit of being simple to implement:

  • error handling logic is completely self contained in the specialized - lower super
  • restart behavior can be factored out and called from any variety of specialized super strategies
  • can an exit stack be used to compose multiple strats?

Further questions:

  • how will the API differ for strats pertaining to process restarts vs. remote task restarts
    • is there even a difference from a user's perspective presuming the conditional of:
      a secondary actor exists -> a remote user defined task is running in that actor.
  • how can this interplay with resiliency designs and decentralized fail-over patterns
  • does dynamic supervision really mean anything different for us?
    • If we encap logic in appropriately written cntx mngs there's no difference whether 1 vs. N actors / tasks are spawned right?

@goodboy goodboy added supervision and removed enhancement New feature or request labels May 1, 2021
@goodboy
Copy link
Owner Author

goodboy commented May 1, 2021

tenacity is an interesting project that seems to be defacto for python restarts.

I think the most compatible (though not fully convinced yet) api that we might want to adopt is the code block retrying.

njs just proposed better native trio support as well.

@goodboy
Copy link
Owner Author

goodboy commented May 7, 2021

A nice short post from @catern affirming the supervisor at every layer design is the future of process management.

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

No branches or pull requests

1 participant