Erlang: which control tree should be completed by writing a task scheduler?

Mostly for educational purposes, I'm trying to write a task (the task is open_port ({spawn_executable, Command})) scheduler.

I end up with a tree like

        supervisor
        |        |
scheduler        receiver
gen_event        gen_event
                     |
                supervisor
                     |
                dispatcher
                gen_server
                     |
                supervisor
                |    |   |
             task1  ... taskN

In other words:

  • top supervisor launches the scheduler and receiver and ensures that they are alive
  • the receiver starts the middle supervisor
  • the middle manager starts the dispatcher and is sure that he will be alive
  • dispatcher starts the bottom dispatcher
  • the lower supervisor starts tasks upon request and guarantees their restart in case of an error

  • at any time, the scheduler is ready to accept the task with a timestamp that he must complete in

  • when a timestamp is encountered, it notifies some event_manager
  • -, , , .
  • , , , -
  • , -
  • , -

:

  • ?
  • ? ( .)
  • + + 4 ?
  • + + , , gen_event + gen_server + supervisor?
  • , OO? ( 3 4.)

.

. . , , ; , (, , , , - ). ?

+1
1

, , :

        supervisor
        |        |
 dispatcher      |
 +scheduler      |
                 |
            supervisor
            |    |   |
         task1  ... taskN

, , .. .

- , , gen_server. , handle_info, api gen_server.

- gen_server , , , "".

/ supervisor:start_child, .

: / node, . , , pool .

:

  • , gen_event , , , , . gen_event - , , 1:1. , .

  • , , , OO . . , Erlang, , , , . , , .

3 + 4. . .

  • OO. OTP - , .

, ( ), , , rpc . pool, . ( ), .

+1

Source: https://habr.com/ru/post/1653466/


All Articles