/ Consensus / Proposing / Detecting Tension
Detecting Tension
is responsible for detecting when the local proposal flow is tensed, meaning if the consensus has consumed more local proposals than being staged.
DetectingTension
is a simple Pipeline
- a persisted input stream : Input.hs
- a line of Pipes Welded together in Pipeline.hs
- Sourcing initial inputs :
stream infinitely inputLog
DetectingTensedFlow
: A pipe that detects a tensed flow in Pipe.hs using StateMachine.hs- A Welding : Adapting IOs between pipes
- Sinking final outputs :
sinking outputLog
- Sourcing initial inputs :
- a persisted output stream : Output.hs
From A CQRS point of view, DetectingTension
is a projection. It projects outputs from events previously recorded in the system.
DetectingTension
is Polymorphic by the Log Engine used.
You'll find in this folder a concrete pipeline version in Pipeline.hs over the event store
DetectingTension
has some DevOps features as well
- Settings.hs always into a separated project
xxxx-detecting-tension-settings
for deployment purposes in Zeus - Dependencies.hs are derived from Settings if sub-dependencies are all Healthy
- Perform the HealhtChecks to obtain the pipeline dependencies
- Execute the pipeline + load the junctions in the EventStore Microservice
- Put the Microservice back in HealthCheck mode if any Exception bubbles up in the pipeline during execution.
N.B : Microservice configuration and Deployment (Locally/Simulated/Production etc...) are defined in the package Zeus
A Junction (Merger) is
- a set of persisted input streams
- a nondeterministic logic for merging these input streams
- a persisted output stream (input of a pipeline)
The persisted input stream is the junction of 2 upstreams pipelines
- Consening :
Local Proposal Accepted
Consensus Reached
- Staging with
Local Proposal Staged
We are using the "User Defined Projections" EventStore feature to implement this junction
- javaScript snippets
- loaded in the event store microservice directly
- more details : https://eventstore.org/docs/projections/api/index.html
Defined in Junction.hs
Executed in Executable.hs
The pipeline does not execute commands but just fold
previous events recorded into the system to provide insights to the downstream flow.
In this situation, it will provide information for optimising the flow
management (purging requests accumulated in the Staging pipeline)
data Input
= LocalProposalAccepted -- ^ local proposal has been accepted by the consortium
| LocalProposalStaged -- ^ local proposal has been staged by the local staging pipeline
| ConsensusReached -- ^ A global consensus has been reached for the proposals of the current block,
-- All the proposal accepted will be consumed.
Defined in Input.hs
The pipeline will output
data Output = Tensed deriving (Eq, Show
This output will be sinked and used in the Staging junction pipeline.
Detect if the local proposal flow is tensed, meaning if the consensus has consumed more local proposals than being staged.
We'll transpose our terminology from the specific consensus domain to a more generic one
instance Weldable DetectingTension.Input DetectingTensedFlow.Input where
weld
= \case
DetectingTension.LocalProposalAccepted -> DetectingTensedFlow.Released
DetectingTension.LocalProposalStaged -> DetectingTensedFlow.Staged
DetectingTension.ConsensusReached -> DetectingTensedFlow.Pulled
A flow is tensed when
- all the items staged have been released and pulled
- we are pulling on
items staged - items release == 0
Implemented in Pipe.hs and StateMachine.hs
Tested in StateMachineSpec.hs