This library abstracts over functional processing units called ChainLink
s and Chain
s. Each link in the chain is meant to be independent, immutable, idempotent, parallelizable, and highly testable.
ChainLink
is an independent processing unit that receives an input and sends an output.
chain_link!
macro you can quickly construct the internals of the mapping from input to output.Chain
is a concatenation of ChainLink
s (and other Chain
s) and is a natural extension of this methodology for processing.
chain!
macro you can concatenate both ChainLink
s and Chain
s naturally.split_merge!
macro permits parallel processing multiple ChainLink
implementations, round-robin iterating over them per send
.
ChainLink
returns None
, it will try the next one, etc.You will want to determine what the smallest unit of processing your project consists of so that you can begin to create ChainLink
s. Defend the quality of your ChainLink
s by creating rigorous unit tests. After you have created a few ChainLink
s bring it all together with a Chain
.
Each type of processing unit (ChainLink
and Chain
) accept in an optional initializer, allowing for dependency injection. Now, it is possible to share dependencies between ChainLink
s of a Chain
, but that is highly discouraged without unit tests around the Chain
.
This example demonstrates how a ChainLink
may exist to pull records from a database and map them to a model.
I have always wanted highly testable code and to work in an environment where the logic of my processes was absolutely dependable.
send
from one ChainLink
to make its way to different destination ChainLink
s based on a conditional block per destination, allowing logical, asynchronous splitting of processing.