typescript-pipeline
v1.0.4
Published
Allows for assembling queues and processing blocks asyncronously. Handles all wiring. Queues are via plugins.
Downloads
7
Readme
README
What is this package for?
Quick summary
This is a data pipeline framework that runs in NodeJS. The pipeline is composed of processing blocks which have a deifined input contract and a defined output contract. All the block needs to do is handle when an input contract is passed in, and needs to emit the output contract. The routing, queuing, error capture, and pushing to the next processing block are handled for you.
How do I get set up?
- Installation
npm install --save typescript-pipeline
- Configuration
- Create the contracts. Each contract should extend "Contract".
- A contract is just a series of properties.
- There is a
validateStructure()
method which needs to be implemented. It should return true or false. This should only check the structure and not be used to validate the values.
- Create the processing blocks. Each block needs to extend 'Block'.
- In the constructor, you should call
setInputContract(Class)
andsetOutputContract(Class)
which will tell the pipeline what input and output to expect. - Implement the "handle" method which will get a single instance of the defined contract passed
in. Outputs are sent by calling
this.emit('data',outputContract)
. This is where the logic for the block resides.
- In the constructor, you should call
- Create a new Pipeline.
let pipeline = new Pipeline();
- Register the blocks.
pipeline.registerBlock(block1);
- You can only register a block one time. You can have multiple blocks of the same type, but each block can only be assigned once.
- Bind the blocks.
pipeline.bindBlocks(block1, block2, options, plugin)
- Binding two blocks creates "mortar" to bind the blocks.
- The options argument is optional.
logContractsToConsole
is a boolean and will cause the mortar to dump out all contracts to the console when they first enter the mortar.
- Specifying a plugin is optional See the plugins section below. If a plugin is not specified, then the mortar acts as a pass-thru the enforces contract types only.
- Create the contracts. Each contract should extend "Contract".
Logic Flow
TBD
Plugins
TBD
Contribution guidelines
- Writing tests
- Code review
- Other guidelines
Who do I talk to?
Please post any bugs or issues to the issues site at [https://bitbucket.org/pythagorasio/typescript-pipeline/issues]