| Safe Haskell | Safe-Inferred |
|---|---|
| Language | GHC2021 |
Hydra.Events
Description
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 SQLiteBased for the default implementation and
SQLiteBasedSpec 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 {
- sourceEvents :: HasEventId e => ConduitT () e (ResourceT m) ()
- getEvents :: (HasEventId e, MonadUnliftIO m) => EventSource e m -> m [e]
- data EventSink e m = EventSink {
- putEvent :: HasEventId e => e -> m ()
- putEvents :: HasEventId e => [e] -> m ()
- mkEventSink :: Monad m => (HasEventId e => e -> m ()) -> EventSink e m
- putEventsToSinks :: (Monad m, HasEventId e) => [EventSink e m] -> [e] -> m ()
Documentation
class HasEventId a where Source #
Methods
getEventId :: a -> EventId Source #
Instances
| HasEventId Word64 Source # | |
Defined in Hydra.Events Methods getEventId :: Word64 -> EventId Source # | |
| HasEventId (StateEvent tx) Source # | |
Defined in Hydra.HeadLogic.StateEvent Methods getEventId :: StateEvent tx -> EventId Source # | |
newtype EventSource e m Source #
Constructors
| EventSource | |
Fields
| |
getEvents :: (HasEventId e, MonadUnliftIO m) => EventSource e m -> m [e] Source #
Retrieve all events from the event source as a list.
Constructors
| EventSink | |
Fields
| |
mkEventSink :: Monad m => (HasEventId e => e -> m ()) -> EventSink e m Source #
Create an EventSink from a single-event function, with a default
sequential batch implementation.
putEventsToSinks :: (Monad m, HasEventId e) => [EventSink e m] -> [e] -> m () Source #
Put a list of events to a list of event sinks, batching per sink.