Saga
in package
Table of Contents
Properties
- $compensate : array<string|int, mixed>
- $continueWithError : bool
- $parallelCompensation : bool
Methods
- addCompensation() : void
- compensate() : CancellationScopeInterface
- Run compensation strategy. Make sure to yield on tis method.
- setContinueWithError() : self
- continueWithError gives user the option to bail out of compensation operations if exception is thrown while running them. This is useful only when parallelCompensation is false. If parallel compensation is set to true, then all the compensation operations will be fired no matter what and caller will receive exceptions back if there's any.
- setParallelCompensation() : self
- This decides if the compensation operations are run in parallel. If parallelCompensation is false, then the compensation operations will be run the reverse order as they are added.
Properties
$compensate
private
array<string|int, mixed>
$compensate
= []
$continueWithError
private
bool
$continueWithError
= false
$parallelCompensation
private
bool
$parallelCompensation
= false
Methods
addCompensation()
public
addCompensation(callable $handler) : void
Parameters
- $handler : callable
compensate()
Run compensation strategy. Make sure to yield on tis method.
public
compensate() : CancellationScopeInterface
Return values
CancellationScopeInterfacesetContinueWithError()
continueWithError gives user the option to bail out of compensation operations if exception is thrown while running them. This is useful only when parallelCompensation is false. If parallel compensation is set to true, then all the compensation operations will be fired no matter what and caller will receive exceptions back if there's any.
public
setContinueWithError(bool $continueWithError) : self
Parameters
- $continueWithError : bool
-
whether to proceed with the next compensation operation if the previous throws exception. This only applies to sequential compensation. Default is false.
Return values
selfsetParallelCompensation()
This decides if the compensation operations are run in parallel. If parallelCompensation is false, then the compensation operations will be run the reverse order as they are added.
public
setParallelCompensation(bool $parallelCompensation) : self
Parameters
- $parallelCompensation : bool
-
default is false.