Может ли модуль реализовывать несколько behaviours?

59 views
Skip to first unread message

Игорь Викторович Проць

unread,
Aug 12, 2013, 3:45:57 AM8/12/13
to erlang-i...@googlegroups.com
Возникла потребность распаралелить работу хендлера cowboya, на данный момент ситуация решается обычным spawn/3, стартуем 2-3 воркера по необходимости.
Хенделер ковбоя реализует -behaviour(cowboy_http_handler), возник вопрос: можем ли мы добавить еще реализацию  -behaviour(supervisor) ? 

Игорь Викторович Проць

unread,
Aug 12, 2013, 4:07:27 AM8/12/13
to erlang-i...@googlegroups.com
Нашел ответ на свой вопрос: http://stackoverflow.com/questions/6488002/how-to-define-customized-behavior-in-erlang-and-what-can-it-do-for-you?rq=1

As long as the callbacks defined in the behavior don't conflict with a callback of another behavior (say you defined your own behavior, for example) then there's nothing wrong with doing this other than potentially more confusing code. Obviously you can curb that with some well placed comments and laying the code out sensibly in the file.
Reply all
Reply to author
Forward
0 new messages