Grains routing
On multiple occasions it seemed useful to route certain messages to some successors, but not all. There is the possibility to push to a grain by name, but that introduces coupling which should be avoided.
I imagine a recipe like this:
%{
A => route({:foo, _}, B),
B => route([
{{:foo, _}, [C, D]},
{:bar, E}
]),
C => route({:fu, periodic(X, 100)})
}
The fundamental idea is that a basic route consist of patter matching expression and the short name of the grain that will receive the messages that match (example starting with A
).
Everything else are just convenient ways of expressing more complex routing, which will be complied down to the basic routes.
@evnu suggested that this should be implemented directly in GenGrain.push
to be efficient.
This will make the breads a good chunk more complex, but I think this is a worthwhile trade off.