| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
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
- data Projection stm event model = Projection {}
- mkProjection :: MonadSTM m => model -> (model -> event -> model) -> m (Projection (STM m) event model)
Documentation
data Projection stm event model Source #
Projection type used to alter/project the API output to suit the client needs.
Constructors
| Projection | |
Arguments
| :: MonadSTM m | |
| => model | |
| -> (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