how to break the problem. the erlang way?
Ovidiu Deac
ovidiudeac@REDACTED
Fri Jul 31 16:47:42 CEST 2009
I'm doing some evaluation of erlang so I came with the following problem:
"The application has to subscribe to a multicast address and receive
binary packets. One packet per datagram. Each packet has a lenght, a
sequence number and a number of messages inside. Packets have to be
processed in their sequence number order. The messages have to be
extracted from the packets and written in a file."
I come with C++/Python experience and in OO approach I would have the
following components:
1. A Receiver who connects to the multicast and receives the packets
2. An Orderer who's responsability is to order the packets by their
sequence number and detect the missing ones.
3. An Unpacker who's responsability is to unpack the incomming packets
and extract the messages.
4. A Decoder who does the deserialization of the messages
5. A Writer who puts the messages in the file.
Now if I move all this to Erlang I would map the objects to processes.
Instead of having objects with methods being called I have processes
which receive messages. So the 5 components would run as separate
processes. Each one does a little job and passes the result to the
next one.
Is this the Erlang way? Or is it just too much message passing overhead?
More information about the erlang-questions
mailing list