[erlang-questions] Using gen_server or writing a new behavior

Christian <>
Fri Jan 16 17:30:01 CET 2009


On Fri, Jan 16, 2009 at 16:21, Ciprian Dorin, Craciun
<> wrote:
>    Hello all!
>
>    I have a somehow philosophycal question about OTP, mainly about
> gen_server...
>
>    I want to write my own HTTP framework, the main focus now being
> the request handlers... So:
>    * I created a request handler supervisor, which managed the
> request handlers;
>    * each connection handler after resolving the request handler,
> delegates the request to it;

This is how I have it:

* each request is a process that look at the method, url, etc,
dispatch to functions that parse what is needed, such as posted bodies
or query args.
* all the data goes into a function that calls plain ordinary
gen_servers (if they need to at all!), still in the same process
* the result is sent to a template function that renders the result
values to something htmlish, and still in the same process.

This is because sending each request directly into a gen_server will
limit concurrency. While it processes one requests, others could be
_waiting to be served_. The latter being the problem.

Additionally, my way the gen_servers that I do need, for ordering
access to some resources, have no dependencies on http requests. They
instead expose the sanest messages possible for the manipulations to
the resource they keep.

You should probably look into "beepbeep" since it does pretty much
exactly what i describe. It also uses erlydtl which is a pretty cool
template language.



More information about the erlang-questions mailing list