Live stream about pluggable message routing: some questions

Quick update on this thread as it has generated some good discussion.

I've made some good progress on the design and now also have a fully working implementation. Which is nice.

The hook names have been updated to better reflect what they are for and to be more consistent around the use of the on/pre/post prefixes.

  1. preSend -> onSend - passed an array of SendEvent objects. The messages inside these objects are exactly what the node has passed to node.send - meaning there could be duplicate references to the same message object.
  2. preRoute - called once for each SendEvent object in turn
  3. onSend -> preDeliver - the local router has identified the node it is going to send to. At this point, the message has been cloned if needed.
  4. postSend -> postDeliver - the message has been dispatched to be delivered asynchronously
    (unless the sync delivery flag is set, in which case it would be continue as synchronous delivery)
  5. onReceive - a node is about to receive a message
  6. postReceive - the message has been passed to the node's input handler
  7. onDone , onError -> onComplete - the node has completed with a message

I've also:

  • updated the design note with some more details on the new RED.hooks api this will introduce.
  • added some words to explain the difference between RED.events and RED.hooks as they look similar but serve different purposes.

Some links

I am still looing at how these hooks can be extended to other parts of the lifecycle - starting/stopping/deploying etc - as that will be needed by components such as custom routers or the flow debugger. The question remains whether they will be hooks (which can modify the data passing through) or events (which are outside observers to the data).