Configuration.chain()
Description
Appends a chain filter to the current pipeline layout.
When given a list of module filenames, a chain filter starts a module chain and links to the entry pipeline for the first module.
When no arguments are present, a chain filter links to the entry pipeline for the next module on the current module chain.
- INPUT - Any types of Events.
- OUTPUT - Events streaming out from the selected sub-pipeline.
- SUB-INPUT - Events streaming into the chain filter.
- SUB-OUTPUT - Any types of Events.
Module and entry pipeline
In Pipy, a module is a standalone script file defining a bunch of pipeline layouts (See Module in Concepts). Every module can have an entry pipeline layout, which is defined by using pipeline() without providing a name. The entry pipeline layout is the starting point to link to while referring a module as a whole from other modules.
Module chain
Modules can be organized into a "chain of modules", where processing starts from the first module and passes down the module chain in order. Each module, after receving and processing the input, decides if the modules after it would get to continue processing.
Start a chain
Calling chain() with an array of module filenames starts a module chain. All inputs to the chain filter would go to the entry pipeline of the first module on the chain. All outputs from that first module would become the chain filter's output as well.
pipy().listen(8000).demuxHTTP().to($=>$.chain(['module-1.js','module-2.js','module-3.js',]))
Pass to the next
Calling chain() with no parameters would link to the entry pipeline of the next module on the current module chain. The current module chain is the chain that has started from the nearest chain filter up in the parent pipelines.
pipy().pipeline() // The entry pipeline layout.handleMessageStart(msg => doSomething(msg)).chain() // Link to the next module on the current module chain
For more information about module chains, please see Tutorial Step 7: Plugins for how a plugin system can be built using module chains.
Syntax
pipy().pipeline().chain([ ...moduleFilenames ])pipy().pipeline().chain()
Parameters
chain(modules?)
An array of module filenames.
The same Configuration object.