The idea I put forward for a change to pn_messenger_route()
may have seemed not very well motivated.
Here is a more complete example, and a more complete
suggestion.
Example
===================================================
All of these nodes are Messenger nodes.
1. Sender
You have a node that's a sender.
It is sending to only abstract addresses.
It uses its routing table to map all its abstract
addresses to the same receiver -- because that receiver
is where the system centralizes knowledge about
changing network conditions.
Sender's routing table
----------------------------------
COLOSSUS --> 1.2.3.4:6666
GUARDIAN --> 1.2.3.4:6666
HAL9000 --> 1.2.3.4:6666
SKYNET --> 1.2.3.4:6666
2. Router
You have a "router" node that is listening on 1.2.3.4:6666 .
It receives and then forwards messages.
It can do this because the messages it receives from
Sender still have their untranslated addresses.
It has this routing table
-----------------------------------
COLOSSUS --> 5.6.7.8:1234
COLOSSUS --> 5.6.7.9:1234
GUARDIAN --> 5.6.7.23:3456
HAL9000 --> null
SKYNET --> 5.6.7.99:6969
3. Adapting to changing conditions
The 'router' node can change its address translation
table based on messages that it receives from other parts
of the network. For example, maybe it does load-balancing
this way.
But in general -- it needs to change its translation table
at run time because conditions in the network are changing.
It is the node that encapsulates knowledge about those changes
so that the rest of our nodes do not need to worry about it.
They just send to "COLOSSUS" or whatever.
This implies that we should be able to change routing
dynamically.
4. Fanout
Note that there are two translations for COLOSSUS.
We send to both of them. ( This is a change. )
This is how we implement fanout with the address translation.
5. Load and Store
Since the translation table can change due to changing
network conditions, the Router node should be able to
store its table to a file, and load from that file.
The information that it has "learned" during operation
is not lost. Or it can use this facility to fork off
another copy of itself.
6. API changes
It seems to me that the address translation functionality
is potentially very powerful, with a few teensy changes.
Here they are:
/*=========================================================
At send time, the messenger examines its translation
table, and sends a copy of the message to each matching
address. ( this is a change )
The address stored in the message is not changed.
( this is true now. )
=========================================================*/
/*-------------------------------------------
Append the given translation to the list.
-------------------------------------------*/
pn_messenger_route_add ( pn_messenger_t *messenger,
const char *pattern,
const char *address );
/*-----------------------------------------------------
If the given pattern already exists in the list,
replace its first occurrence with this translation.
Otherwise add this translation to the list.
-----------------------------------------------------*/
pn_messenger_route_replace ( pn_messenger_t *messenger,
const char *pattern,
const char *address );
/*-----------------------------------------------------
Delete the given translation from the list.
( Else, NOOP. )
-----------------------------------------------------*/
pn_messenger_route_delete ( pn_messenger_t *messenger,
const char *pattern,
const char *address );
/*-----------------------------------------------------
Delete from the list all translations with this
pattern.
-----------------------------------------------------*/
pn_messenger_route_delete_pattern ( pn_messenger_t *messenger,
const char *pattern );
/*-----------------------------------------------------
Clear the translation table.
-----------------------------------------------------*/
pn_messenger_route_clear_table ( pn_messenger_t *messenger );
/*-----------------------------------------------------
Load from the given fp
-----------------------------------------------------*/
pn_messenger_route_load_table ( pn_messenger_t *messenger,
FILE * fp );
/*-----------------------------------------------------
Store to the given fp
-----------------------------------------------------*/
pn_messenger_route_load_table ( pn_messenger_t *messenger,
FILE * fp );