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.

Sunday, February 19, 2012

Comments: megaphone_receiver

Previously...
  • I started testing the send functionality.
  • I finished testing the send functionality (go me!).
  • I created comments for the megaphone module.

This time around I created some comments for the non-test methods of the megaphone_receiver module.  One thing of note that I discovered was that one of the functions to defined, to get the status of the module, would not work.  The reason for this goes back to the reason for creating the module in the first place.

At this point, I know of no way to listen at a socket and to listen for an erlang message at the same time.  Since the subsystem needs to listen for messages to send as well as new data, there is a need for this process.  The thing is, this process is busy listening for new data over the TCP port so it will not hear other messages telling it to respond to a status message or to shutdown.  

Therefore the status API function will never work with the module in its current form: because the status message would come in via the erlang message route instead of the TCP route, the process would never see it.  In the spirit of code cleanup, I therefore removed it.

This may seem like a small and trivial detail.  That's because it is.  But it does illustrate the larger point of cleaning up code.  Without cleanup, source code accumulates non-functional effluvia that makes the code harder to understand.  Performing cleanup is vital to keeping the forces of entropy at bay.

Of course, the laws of thermodynamics tell us that this is all a waste of time and that chaos will win in the end, but still...

Next time: commenting megaphone_send.

No comments:

Post a Comment