gen_statem and simple_one_for_one supervisor
Stanislav Ledenev <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CAOkK=ALe8T-1W2iy+S=XtybhiZUdRD5DtkOAm3sAoASYvOepyg@mail.gmail.com> |
Hi, In my application I have simple_one_for_one supervisor for handling incoming external requests (HTTP). Each request has some command and its arguments. Each command has its own workflow and that is why commands handler is implemented as gen_statem. This gen_statem handles all commands and I don't like that kind of a code mess inside of it. I have two thoughts in my mind about resolving this problem, but I don't like them either: 1. Create multiple simple_one_for_one supervisors, one for each type of command. I don't think that so many supervisors is a good idea; 2. Create "general" gen_statem for supervisor and multiple handling modules which then be passed as arguments to supervisor's init. I don't like general over general and so on (yuck!). Is there any elegant way to solve this kind of a problem and keep this nice pair of simple_one_for_one supervisor and gen_statem?