actionhero_client is a nodeJS package to allow a remote nodeJS app to connect to / consume an actionHero API.
The most intersting part of creating this client was dealing with the notion that you can have more than one 'pending' request out to the API at any moment. While node.js developers are used to to dealing with parallel and async functions, I still always thought of remote requests in the HTTP way, mainly that I could always assume each request would be responded to with only one and only one response. This isn't true in raw socket land!
If I were to request
slowAction and then
fastAction, it's likely I would receive the response to
fastAction first. actionHero makes use of a request counter (messageCount) for each request so that clients can differentiate responses, and know which call they were related to. I adopted the "holding pen pattern" (I made this term up just now) which stores async callbacks until a relevant response has been returned from the API. This still allows folks to use the common
method(data, callback) pattern, but in a very unlinked w Anyway... npm install actionhero_client and you are good to go!quests and limit the number of 'active' queries (coming in a future version), and to timeout requests which take to long.
<< Exception Patterns in node.js What do you do when softpedia scrapes you projects? >>