[erlang-questions] Parenting needed

Sami Väisänen <>
Wed Oct 4 15:19:44 CEST 2006


Hello,

First off some background information. I have an application (written in
C++) that loads some plugins, i.e. .so libraries. The application also
registers itself as an erlang node and is able to receive messages from
other Erlang nodes on the network and respond to those. It has some
built in functionality but for the most part it will just act as a
gateway between the plugins and the erlang environment by passing
messages (and arbitrary message data in tuples) to a given plugin and
then sending back the response. Some of the operations performed by the
plugins will be asynchronous, i.e. be performed in a separate thread and
will later result in the generation of response event(s).

The basic premise is that the C++ application remains fairly simple,
unaware of the distributed nature of the system and just enables new
functionality (i.e. legacy C/C++ code) to be plugged into the system
fairly easily.

Now Im in the process of building a distributed layer on top of the the
C++ application so that the distributed Erlang nodes will "abstract
away" a particular configuration of the C++ application. As an example
on computer C1 I might have the C++ application running with plugins P1
and P2, on computer C2 the same application running with only plugin P3.
Yet to any client connecting to the system (TCP connection) to any
Erlang node, the client should be able to see all features of the system
irrespective of the node the client is connected to. I.e. a client
connecting to computer C1 should be able to request service from plugin
P3 transparently.

In a similar fashion any events generated by the background threads
within the plugins should be propagated througout the system among some
"publishable" system wide data.

Erlang is a wholly new environment to me, and I have just been working
with it for a few weeks with mainly writing code to interact with the
C++ application (which I also wrote). I have just finished reading Joe
Armstrong's thesis about how to build fault tolerant distributed
applications and have grasped the basic ideology behind behaviours and
reusing components such as gen_server. However what I dont understand is
how to incorporate these patterns into the system Im about to build.

In other words what I'm asking is some kind of general guidelines or
ideas how to possibly structure the system and what to start looking at.
Basically just gentle poking in the right direction.

Im sure that with some hacking I could translate a basic C++ based
design into equivalent Erlang code (and save a lot of time while doing
it), but Im afraid this would not be "idiomatic" use of Erlang and would
result in "WTF"ism and less than desirable implementation.

So if anyone bothers to offer some parental guidance that would be
greatly appreciated.

Thank you and sorry for the lengthy post.

- Sami





More information about the erlang-questions mailing list