[erlang-questions] When to use gen_server?

Navin Parray navinparray@REDACTED
Wed Jan 11 23:17:23 CET 2012


Hello everyone,

I'm developing a backend with Erlang/OTP and I need advice on the type of
behaviours I should use for the various applications. The code is broken
into four areas. One is a webmachine REST interface called myapp_webapi.
This calls an application called myapp_core. myapp_core provides an
abstraction of the data access layer. The data access layer consists of two
applications, myapp_store and myapp_indexer. myapp_store connects to a Riak
database while myapp_indexer connects to an ElasticSearch engine.

My confusion lies in not knowing what type of behaviour the various layers
should implement. Should the myapp_core be a gen_server or a basic
application? Similarly, what about the myapp_store and myapp_indexer
applications? I'd like to understand the reason I would chose one over the
other in this situation.

I could do this by simply calling modules in the webmachine application but
I want to keep the areas separated because I will need to provide a second
REST interface for another application. This would use the same data but
only required read access to a couple data points and would be used by the
public whereas myapp_webapi is used by my frontend applications only. I
would need to call myapp_core from that application also.

Regards
Navin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120111/fbdace8e/attachment.htm>


More information about the erlang-questions mailing list