OsPipelineChainStarter
Description
Instances of this class are used to help configure and start pipelines chains.
A pipeline chain is a logical connection between two processes, pipelines or pipeline chains. A pipeline chain starter defines a left-hand side, a right-hand side and a logical operator between them. The operator is used to control how (or if) execution proceeds from the left-hand side to the right-hand side.
Users typically won't directly instantiate an OsPipelineChainStarter, but instead they can use messages like =>, &&, || on <OsProcessStarter>, <OsPipelineStarter> and other <OsPipelineChainStarter> instances
Sequence Operator =>
The right-hand side will begin only after the left-hand side finishes. This is different from a pipe, where both the left and right-hand sides are executing at the same time.
AND Sequence Operator &&
The right-hand side will begin only once the left-hand side finishes AND the exit code of the left-hand side is considered success (by default, an exit code of 0).
OR Sequence Operator ||
The right-hand side will begin only once the left-hand side finishes AND the exit code of the left-hand side is considered a failure (by default, an exit code ~= 0).
Defining Success
By default, success is defined as an exit code of 0. Conditional operators will test against this to perform their respective logic. However, the user may redefine what success is with an exit code or even a lazy evaluated block. Use OsPipelineChainStarter>>success: to set the success code or block
Examples
The following are some examples on Windows that show how the logic works. Copy this to a workspace
"Example - Chaining => && ||"
| pipelineChain str launchNotepadCmd launchNotepadTwiceCmd |
"Setup the starter for launching notepad"
launchNotepadCmd := OsProcessStarter new command: #('notepad.exe').
"Sequence"
launchNotepadTwiceCmd := launchNotepadCmd => launchNotepadCmd.
pipelineChain := launchNotepadTwiceCmd start.
pipelineChain waitForCompletion.
str := pipelineChain outputStream upToEnd trimSeparators.
"Chaining with &&"
launchNotepadTwiceCmd := launchNotepadCmd && launchNotepadCmd.
pipelineChain := launchNotepadTwiceCmd start.
pipelineChain waitForCompletion.
str := pipelineChain outputStream upToEnd trimSeparators.
"Chaining with ||"
launchNotepadTwiceCmd := launchNotepadCmd || launchNotepadCmd.
pipelineChain := launchNotepadTwiceCmd start.
pipelineChain waitForCompletion.
str := pipelineChain outputStream upToEnd trimSeparators.
Class Methods
new
Answer a new initialized instance
Answers:
<OsPipelineChainStarter>
Instance Methods
&&
Answer a conditional sequence pipeline chain.
aSequenceableStarter will start as soon as this pipeline chain starter finishes
IF the exit code from this pipeline chain is considered success (by default, an exitcode of 0)
Arguments:
aSequenceableStarter - <OsProcessStarter | OsPipelineStarter | OsPipelineChainStarter>
Answers:
<OsPipelineChainStarter>
=>
Answer a sequence pipeline chain.
aSequenceableStarter will start as soon as this pipeline chain starter finishes
Arguments:
aSequenceableStarter - <OsProcessStarter | OsPipelineStarter | OsPipelineChainStarter>
Answers:
<OsPipelineChainStarter>
|
Answer a pipeline, or pipeline chain, that is configured to feed the output from this
starter into the input of @aPipelineableStarter.
The execution of this pipeline will perform the starters in parallel
Arguments:
aPipelineableStarter - <OsProcessStarter | OsPipelineStarter | OsPipelineChainStarter>
Answers:
<OsProcessStarter | OsPipelineStarter | OsPipelineChainStarter>
||
Answer a conditional sequence pipeline chain.
aSequenceableStarter will start as soon as this pipeline chain starter finishes
IF the exit code from this pipeline chain is considered a failure code (by default, an exitcode ~= 0)
Arguments:
aSequenceableStarter - <OsProcessStarter | OsPipelineStarter | OsPipelineChainStarter>
Answers:
<OsPipelineChainStarter>
lhs
Answer the left-hand side relative to the operator
Answers:
<OsProcessStarter | OsPipelineStarter | OsPipelineChainStarter>
lhs:
Set the left-hand side to apply to the chaining operator.
Arguments:
aPipelineableStarter - <OsProcessStarter | OsPipelineStarter | OsPipelineChainStarter>
Answers:
<OsPipelineChainStarter>
operator
Answer the chaining operator to apply to the
left and right-hand side.
OsPorcessConstants::PipelineChainingAndOp
Execute the rhs only if the lhs exits successfully.
@see shouldEvalRhsBlock for definition of success
OsProcessConstants::PipelineChainingOrOp
Execute the rhs only if the lhs exits unsuccessfully.
@see shouldEvalRhsBlock for definition of success
OsProcessConstants::PipelineChainingSeqOp
Execute the lhs. Once the lhs completes, then
execute the rhs
Answers:
<Symbol> one of the symbols above
operator:
Set the chaining operator to apply to the
left and right-hand side.
OsPorcessConstants::PipelineChainingAndOp
Execute the rhs only if the lhs exits successfully.
@see shouldEvalRhsBlock for definition of success
OsProcessConstants::PipelineChainingOrOp
Execute the rhs only if the lhs exits unsuccessfully.
@see shouldEvalRhsBlock for definition of success
OsProcessConstants::PipelineChainingSeqOp
Execute the lhs. Once the lhs completes, then
execute the rhs
Arguments:
anOperator - <Symbol>
Answers:
<OsPipelineChainStarter>
pipelineChainClass
Answer the implementation class for
an os process pipeline chain
Answers:
<Object>
pipelineChainClass:
Sets the implementation class for
an os process pipeline chain
Arguments:
aPipelineChainClass - <Object>
rhs
Answer the right-hand side relative to the operator
Answers:
<OsProcessStarter | OsPipelineStarter | OsPipelineChainStarter>
rhs:
Set the right-hand side to apply to the chaining operator.
Arguments:
aPipelineableStarter - <OsProcessStarter | OsPipelineStarter | OsPipelineChainStarter>
Answers:
<OsPipelineChainStarter>
start
Starts and answers a new pipeline chain.
If an exception occurs, wait for everything in
the chain to be killed and then re-signal the
exception
Answers:
<OsPipelineChain>
Raises:
<OsProcessException>
success:
Set the object that will be compared (or evaluated) against
the exit code of this chain for success.
By default, success is defined as an exit code of 0
Arguments:
anIntegerOrBlock - <Integer> exit code defining success
- <Block> 1-arg block with <Integer> exitCode arg
Last modified date: 07/07/2022