-
-
Notifications
You must be signed in to change notification settings - Fork 52
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
guillheu
wants to merge
22
commits into
gleam-lang:main
Choose a base branch
from
guillheu:simple-one-for-one-erlang
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ild_with_args` function
…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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Implementing #42
Following lpil' recommendation, I started from the
static_supervisor
module, which uses Erlang'ssupervisor
module. I added bindings to the following Erlangsupervisor
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 thesimple-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 likeadd_child
,terminate_child
andcount_children
, while the equivalent functions for theSimpleSupervisor
are prefixed withsimple_
(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 wasstatic_supervisor
, anyone using thestatic_supervisor
can use the newerlang_supervisor
instead. As a result, I took the initiative to deprecate all the functions in thestatic_supervisor
module (apologies if that's overreach on my part).Because of how different the
Supervisor
andSimpleSupervisor
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.