valid use for gen_server?
Thu Sep 30 17:38:14 CEST 2010
I'm building a simple IM server and to make it modular I want to let plugins
subscribe handlers to messages (ejabberd hooks, django signals, js listeners).
If the handler is sync it can modify the message and return it or return false
to prevent further processing of the message.
If the handler is async it receives the message but doesn't effect it or other
I see two options to implement the above, gen_event or custom event module.
What bothers me in gen_event is that it executes handlers in its own context.
If events are rare that shouldn't be a problem but if each IM message will fire
several events wouldn't this flood the gen_event server?
I can use a custom event module that saves events and handlers in ETS table and
call functions dynamically with Module:Function(Args).
This also doesn't feel right because each IM message will require several ETS
lookups and dynamic functions calls which according to the efficiency guide are
are 6 times slower than normal calls.
Can you suggest which one is better?
More information about the erlang-questions