Safe Haskell | Safe-Inferred |
---|---|
Language | GHC2021 |
This module defines the types and functions for creating EventSource
and
EventSink
instances and is intended to be used as an extension point.
A single EventSource
and zero or more EventSink
handles are used by the
main HydraNode
handle to load and send out events.
See FileBased
for an example implementation and
FileBasedSpec
for the corresponding test suite.
Custom implementations should be located under Hydra.Events to avoid conflicts.
Synopsis
- type EventId = Word64
- class HasEventId a where
- getEventId :: a -> EventId
- newtype EventSource e m = EventSource {
- getEvents :: HasEventId e => m [e]
- newtype EventSink e m = EventSink {
- putEvent :: HasEventId e => e -> m ()
- putEventsToSinks :: (Monad m, HasEventId e) => [EventSink e m] -> [e] -> m ()
- data StateEvent tx = StateEvent {
- eventId :: EventId
- stateChanged :: StateChanged tx
- genStateEvent :: StateChanged tx -> Gen (StateEvent tx)
Documentation
class HasEventId a where Source #
getEventId :: a -> EventId Source #
Instances
HasEventId (StateEvent tx) Source # | |
Defined in Hydra.Events getEventId :: StateEvent tx -> EventId Source # | |
HasEventId (EventId, a) Source # | |
Defined in Hydra.Events getEventId :: (EventId, a) -> EventId Source # |
newtype EventSource e m Source #
EventSource | |
|
newtype EventSink e m Source #
EventSink | |
|
putEventsToSinks :: (Monad m, HasEventId e) => [EventSink e m] -> [e] -> m () Source #
Put a list of events to a list of event sinks in a round-robin fashion.
State change events as used by Hydra.Node
data StateEvent tx Source #
A state change event with an event id that is the common entity to be
loaded from an EventSource
and sent to EventSink
s.
StateEvent | |
|
Instances
genStateEvent :: StateChanged tx -> Gen (StateEvent tx) Source #