hydra-node-0.20.0: The Hydra node
Safe HaskellSafe-Inferred
LanguageGHC2021

Hydra.API.Projection

Description

Projection module exposes the handle which is our implementation of projections from the CQRS terminology.

Projections allow us to easily tailor the needs of different API clients (related to our ServerOutput messages) and enable us to more easily implement future user needs.

This module provides abstract interface for serving different data from the API endpoints and abstracts over the internal implementation (in this case a TVar).

What we serve from the API server is TimedServerOutputs and Projection allows us to transform these outputs and add more (stateful) information (like the HeadStatus model).

Projections always need to use a function in form of `(model -> event -> model)` where depending on event we are currently dealing with we might want to alter our existing model.

Synopsis

Documentation

data Projection stm event model Source #

Projection type used to alter/project the API output to suit the client needs.

Constructors

Projection 

Fields

mkProjection Source #

Arguments

:: MonadSTM m 
=> model 
-> [event] 
-> (model -> event -> model)

Projection function

-> m (Projection (STM m) event model) 

Create a Projection handle that knows how to:

  • get the latest model state
  • update the model using a projection function