What is Megaphone?

What is Megaphone?
The Megaphone project is about enhancing open source chat software. Specifically, the goal is to allow ejabberd to support 1,000,000 simultaneous users. See The Plan page for more details on how I plan to solve this problem. See the About this Blog page for more details on why I created this blog.

Monday, March 12, 2012

Processing Requests

Previously...
  • I analyzed ways of calling ejabberd_http_bind.
  • I decided on using ejabberd_http_bind:process_request.
  • I came up with a new plan.

I wrote a very small bit of code that takes the data from ECM and passes it on to ejabberd_http_bind:process_request:

put_data(State, ConnectionID, Data) ->
    spawn(?MODULE, process_request, [ConnectionID, Data]).

process_request(ConnectionID, Data) ->
    Response = ejabberd_http_bind:process_request(Data, <<127.0.0.1>>),
    ?MODULE:send(ConnectionID, Response).

One concern that I have with this is that the response may only include the XML and not the HTTP wrapping for the response.  If that is the case, then I will have to write some new stuff to create a response for the data.

One side effect of the new approach is that the whole waiter scheme is no longer needed.  Originally, I thought that some process would read the data and megaphone would block the requesting process until data was actually available.  With this scheme, ejabberd never gets called until data is available, so the whole waiter infrastructure is unnecessary.

Next time: turn it on and see if it works.

No comments:

Post a Comment