abstractive / ecell

Other
8 stars 1 forks source link

Encapsulate response-waiting-and-matching logic #16

Open sarahzrf opened 8 years ago

sarahzrf commented 8 years ago

In many cases, it's less than ideal to use ØMQ's synchronous sockets, but the communication being done is still in one-reply-to-one-request form. ECell's logic for handling these cases is spread out a bit through the code (mostly in Calling, Management, and line_handlers.rb), and is the source of some failures to be DRY.

I think it'd be a good idea to write a new class (or maybe just add methods to Line) that abstract over this use case. Interface-wise, it'd provide a method which you call with the message to send that then synchronously returns the response, so that rep = line << req; rep = rep.wait can be replaced with rep = something.the_method(req).

If done correctly, I think this rid of the need for the hardcoding in Constants::RETURNS.