manhvu

manhvu

SuperWorker - A flat & all in one supervisor

I try to make new supervisor for developer can easy to add & manage processes.

For current supervisors, that is based on OTP & suitable for telecom application and need to think too much for design.
I made a all in one & flat supervisor for newbies can jump and use easily.

Basic idea in here is separated process follow group/chain/standalone.
Support for add all processes from config or by runtime.

Supervisor now can work in basic, you can get it from hex.pm or access source code from Github.com

Basic example:

# Start a supervisor with 2 partitions & 2 groups:
alias SuperWorker.Supervisor, as: Sup

# Config for supervisor
opts = [id: :sup1, number_of_partitions: 2, link: false]

# Start supervisor
Sup.start(opts)

# Add group in runtime, you also can add group in config.
Sup.add_group(:sup1, [id: :group1, restart_strategy: :one_for_all])
Sup.add_group_worker(:sup1, :group1, {Dev, :task, [15]}, [id: :g1_1])

Sup.add_group(:sup1, [id: :group2, restart_strategy: :one_for_one])
Sup.add_group_worker(:sup1, :group2, fn ->
  receice do
  msg ->
    :ok
  end
end, [id: :g2_2])

I’m still working on this and update more details in later!

https://github.com/ohhi-vn/super_worker

Most Liked

asianfilm

asianfilm

All I’m gonna say is that you missed the golden opportunity of creating a library called ÜberWorker.

dimitarvp

dimitarvp

This looks nice, thank you. I would use the chain workers but would be worried about lack of persistence i.e. if we have a chain of 5 steps and the app is restarted while step 3 is executing, I would want step 3 to begin executing anew after the app starts again.

I realize this is no longer a “normal” supervisor logic and goes into the territory of persistent job queues. I am sharing what I would find useful.

Last Post!

manhvu

manhvu

Yes, persistence is lacked. I think in the future I will add a new feature to store state of chain to Ets table or external db.

The idea of supervisor came from my basic use cases and still have a lot of thinks to do.

Where Next?

Popular in Announcing Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
New
OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New
versilov
Could not wait for the missing Elixir ML libraries to appear, so, I wrote one myself, taking https://github.com/sdwolfz/exlearn as a foun...
New
mindok
What is ContEx? A pure Elixir server-side data plotting/charting library outputting SVG. It has nice barcharts in particular and works g...
New
Qqwy
TypeCheck: Fast and flexible runtime type-checking for your Elixir projects. Core ideas Type- and function specifications are const...
336 14774 100
New
trisolaran
Hi! :waving_hand: I would like to present LiveSelect, a little library that I wrote to easily add a dynamic selection input to your LV f...
198 11283 107
New
martinthenth
Hello everybody :wave: Recently, some of my colleagues talked about database ids and uuids and their problems, and I remembered the pain...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New

We're in Beta

About us Mission Statement