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

Implementing Erlang supervisor-based dynamic supervisor #87

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

guillheu
Copy link

Implementing #42
Following lpil' recommendation, I started from the static_supervisor module, which uses Erlang's supervisor module. I added bindings to the following Erlang supervisor functions:

  • start_child/2
  • terminate_child/2
  • restart_child/2
  • delete_child/2
  • count_children/1

I also added a new supervisor type, SimpleSupervisor, which implements the simple-one-for-one strategy. It needed its own type, because it behaves significantly differently with the aforementioned functions than the other strategies. In my opinion, they are different kinds of supervisors altogether.
As a result, the Supervisor can be managed with functions like add_child, terminate_child and count_children, while the equivalent functions for the SimpleSupervisor are prefixed with simple_ (simple_add_child, simple_terminate_child, simple_count_children) to have them clearly stand out and stick together in the hex function index.

I named the new module erlang_supervisor. Since my inspiration was static_supervisor, anyone using the static_supervisor can use the new erlang_supervisor instead. As a result, I took the initiative to deprecate all the functions in the static_supervisor module (apologies if that's overreach on my part).

Because of how different the Supervisor and SimpleSupervisor are, I think there's an argument to split them into separate modules. However they would be using the same Erlang bindings under the hood, so there'd have to be a third internal module for the bindings and other common logic. I wasn't sure how much should be in that internal module and how much should stay exposed, so I didn't split them.

Finally, I updated all the tests of the existing strategies with the new functionalities, and wrote a new test for the simple-one-for-one strategy.

I think some things could be improved, like the error types for the Erlang functions.

…aves differently from the others, and one for the others.
…separate types and functions for the "simple" supervisors. Deprecating `static_supervisor`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant