[erlang-questions] OTP Design Pattern Question/gen_server with different parameters?
Daniel Goertzen
daniel.goertzen@REDACTED
Tue Mar 10 18:51:06 CET 2009
I wonder if you are throwing too many processes and servers at the problem.
Can the solution be implemented by plain old functions within a single
process?
Dan.
2009/3/10 Jonathan Palley <jpalley@REDACTED>
> 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!
> JP
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
--
Daniel Goertzen
-----------------
work email: dang@REDACTED
work phone: 1 443 303 8525
work sip: 945050@REDACTED
-----------------
mobile: 1 204 470 8360
-----------------
home email: daniel.goertzen@REDACTED
home phone: 1 204 272 6149
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20090310/54cb287b/attachment.htm>
More information about the erlang-questions
mailing list