implexus v0.2.0
implexus
This is currently still under development
Takes in a graph describing streams, and builds up the pipeline
npm install --save implexusThe library expects graphs generated through Graphlib, or strings that define graphs in DOT. Nodes are expected to define a type property which points to a defined stream type.
API
The library has a very small surface to make it super easy to integrate with.
Implexus()
Creates a new instance of Implexus.
Implexus.define(type, factory)
Defines a new type of stream that can be used new graphs.
attributes
typeString: The name for the stream type (corresponds to thetypeattribute in nodes)factoryStreamFactory: TheStreamFactoryfunction for creating a node of that type
returns
Implexus: Returns itself for chaining
Implexus.define(modules)
A bulk version of Implexus.define(type,factory)
attributes
modulesObject<type,factory>: A map that contains all thetypes of streams, and points toStreamFactorys which create streams of that type.
returns
Implexus: Returns itself for chaining
Implexus.build(graph, cb)
This parses out the graph, creates streams from the modules, and wires them up.
attributes
graphGraph: This is an instance of a graphlib graphcbFunction(err, graph): Callback that gets called when everything is wired up.graphis a new instance ofImplexusGraph
returns
Implexusreturns itself for easy chaining
StreamFactory(node, cb)
This is the format for the stream factories. It's supposed to take in the data for a graph node, and create a new stream from it.
attributes
nodeObject: The node within the graph that describes the stream.cb: This should get called with either an error object, or match one of the followingFunction(err,stream,[cleanup]): Usually the factory should resolve in a stream, which will be used in the graph. Cleanup is a function used to destroy the created stream.Function(err, fn(chunk, [encoding]),[cleanup]): Alternately, it can return a function that takes in data and an encoding, which gets passed to through2-map to make a streamFunction(err, fn(chunk, encoding, callback),[cleanup]): Same as above, but async, and gets passed into through2 to make a stream.
ImplexusGraph.destroy(cb)
This destroys the created graph of streams. It unpipes all the streams one by one, and calls the cleanup function if one was made by the stream's StreamFactory.
attributes
cbFunction(err): This callback gets called when the graph has been destroyed, or if there was an error during its destruction.
11 years ago

