[erlang-questions] OTP Design Pattern Question/gen_server with different parameters?

Jonathan Palley jpalley@REDACTED
Tue Mar 10 11:35:15 CET 2009

All -   I've got this running in straight Erlang, but trying to understand
how to apply to the OTP pattern.

Wondering the best practice for a system like this:

event comes in (external source) -> various event handlers get sent the
event based on the event type. -> these event handlers will filter the event
to determine if they should send it on (via an http request).

The trick is this: there is an interface to add and delete event handlers
with a filter.

In straight erlang I:
  - Created a new process for each handler.  The handler would be init with
the filters.
  - A central event processor stored the PID of each handler and the event
type it was subscribed to.  As an event would come in it would re-broadcast
to the different handlers.
  - Each handler would then use its custom filter to determine whether to
send it on.

Now, I would like all the robustness that comes with OTP.  Perhaps I am
approaching this incorrectly, but what I can't figure out is:

- If I start multiple instances of gen_event (with different filters each)
and add it to a supervisor tree, there doesn't seem to be a way to identify
the one handler I want to delete (if I want to remove the handler)
- If I create only one gen_event for each event type and make the
event_handlers be gen_server, I run into a similar problem (how do I call
all the gen_servers that I want).

Thanks for any ideas!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090310/08528594/attachment.htm>

More information about the erlang-questions mailing list