Copyright | (C) 2016 Yorick Laupa |
---|---|
License | (see the file LICENSE) |
Maintainer | Yorick Laupa <yo.eight@gmail.com> |
Stability | provisional |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
- data Batch = Batch {}
- data Subscription = Subscription {
- subscriptionId :: SubscriptionId
- nextEvent :: forall m. MonadBase IO m => m (Either SomeException SavedEvent)
- data SubscriptionId
- data ExpectedVersionException = ExpectedVersionException {}
- class Store store where
- data SomeStore = Store store => SomeStore store
- data StreamIterator
- iteratorNext :: StreamIterator -> forall m. MonadBase IO m => m (Maybe SavedEvent)
- iteratorNextEvent :: (DecodeEvent a, MonadBase IO m, MonadPlus m) => StreamIterator -> m (Maybe a)
- iteratorReadAll :: MonadBase IO m => StreamIterator -> m [SavedEvent]
- iteratorReadAllEvents :: (DecodeEvent a, MonadBase IO m, MonadPlus m) => StreamIterator -> m [a]
- streamIterator :: (Store store, MonadBase IO m) => store -> StreamName -> m (ReadStatus StreamIterator)
- freshSubscriptionId :: MonadBase IO m => m SubscriptionId
- startFrom :: EventNumber -> Batch
- nextEventAs :: (DecodeEvent a, MonadBase IO m) => Subscription -> m (Either SomeException a)
- foldSub :: (DecodeEvent a, MonadBase IO m) => Subscription -> (a -> m ()) -> (SomeException -> m ()) -> m ()
- foldSubAsync :: (MonadBaseControl IO m, DecodeEvent a) => Subscription -> (a -> m ()) -> (SomeException -> m ()) -> m (Async (StM m ()))
- appendEvent :: (EncodeEvent a, MonadBase IO m, Store store) => store -> StreamName -> ExpectedVersion -> a -> m (Async EventNumber)
- forEvents :: (MonadBase IO m, DecodeEvent a, Store store) => store -> StreamName -> (a -> m ()) -> ExceptT ForEventFailure m ()
- forEventsWithNumber :: (MonadBase IO m, DecodeEvent a, Store store) => store -> StreamName -> (EventNumber -> a -> m ()) -> ExceptT ForEventFailure m ()
- foldEventsWithNumberM :: (MonadBase IO m, DecodeEvent a, Store store) => store -> StreamName -> (EventNumber -> s -> a -> m s) -> s -> ExceptT ForEventFailure m s
- foldEventsM :: (MonadBase IO m, DecodeEvent a, Store store) => store -> StreamName -> (s -> a -> m s) -> s -> ExceptT ForEventFailure m s
- foldEvents :: (MonadBase IO m, DecodeEvent a, Store store) => store -> StreamName -> (s -> a -> s) -> s -> ExceptT ForEventFailure m s
- forSavedEvents :: (MonadBase IO m, Store store) => store -> StreamName -> (SavedEvent -> m ()) -> ExceptT ForEventFailure m ()
- foldSavedEventsM :: (MonadBase IO m, Store store) => store -> StreamName -> (s -> SavedEvent -> m s) -> s -> ExceptT ForEventFailure m s
- foldSavedEvents :: (MonadBase IO m, Store store) => store -> StreamName -> (s -> SavedEvent -> s) -> s -> ExceptT ForEventFailure m s
- foldSubSaved :: MonadBase IO m => Subscription -> (SavedEvent -> m ()) -> (SomeException -> m ()) -> m ()
- foldSubSavedAsync :: MonadBaseControl IO m => Subscription -> (SavedEvent -> m ()) -> (SomeException -> m ()) -> m (Async (StM m ()))
- data ForEventFailure
- unhandled :: (MonadBase IO m, Exception e) => ExceptT e m a -> m a
Documentation
Represents batch information needed to read a stream.
Batch | |
|
data Subscription Source #
A subscription allows to be notified on every change occuring on a stream.
Subscription | |
|
data SubscriptionId Source #
Represents a subscription id.
class Store store where Source #
Main event store abstraction. It exposes essential features expected from an event store.
appendEvents :: (EncodeEvent a, MonadBase IO m) => store -> StreamName -> ExpectedVersion -> [a] -> m (Async EventNumber) Source #
Appends a batch of events at the end of a stream.
readBatch :: MonadBase IO m => store -> StreamName -> Batch -> m (Async (ReadStatus Slice)) Source #
Appends a batch of events at the end of a stream.
subscribe :: MonadBase IO m => store -> StreamName -> m Subscription Source #
Subscribes to given stream.
toStore :: store -> SomeStore Source #
Encapsulates to an abstract store.
Utility type to pass any store that implements Store
typeclass.
data StreamIterator Source #
Allows to easily iterate over a stream's events.
iteratorNext :: StreamIterator -> forall m. MonadBase IO m => m (Maybe SavedEvent) Source #
iteratorNextEvent :: (DecodeEvent a, MonadBase IO m, MonadPlus m) => StreamIterator -> m (Maybe a) Source #
Reads the next available event from the StreamIterator
and try to
deserialize it at the same time.
iteratorReadAll :: MonadBase IO m => StreamIterator -> m [SavedEvent] Source #
Reads all events from the StreamIterator
until reaching end of stream.
iteratorReadAllEvents :: (DecodeEvent a, MonadBase IO m, MonadPlus m) => StreamIterator -> m [a] Source #
Like iteratorReadAll
but try to deserialize the events at the same time.
streamIterator :: (Store store, MonadBase IO m) => store -> StreamName -> m (ReadStatus StreamIterator) Source #
Returns a StreamIterator
for the given stream name. The returned
StreamIterator
IS NOT THREADSAFE.
freshSubscriptionId :: MonadBase IO m => m SubscriptionId Source #
Returns a fresh subscription id.
startFrom :: EventNumber -> Batch Source #
Starts a Batch
from a given point. The batch size is set to default,
which is 500.
nextEventAs :: (DecodeEvent a, MonadBase IO m) => Subscription -> m (Either SomeException a) Source #
Waits for the next event and deserializes it on the go.
foldSub :: (DecodeEvent a, MonadBase IO m) => Subscription -> (a -> m ()) -> (SomeException -> m ()) -> m () Source #
Folds over every event coming from the subscription until the end of the
universe, unless an Exception
raises from the subscription.
SomeException
is used because we let the underlying subscription model
exposed its own Exception
. If the callback that handles incoming events
throws an exception, it will not be catch by the error callback.
foldSubAsync :: (MonadBaseControl IO m, DecodeEvent a) => Subscription -> (a -> m ()) -> (SomeException -> m ()) -> m (Async (StM m ())) Source #
Asynchronous version of foldSub
.
appendEvent :: (EncodeEvent a, MonadBase IO m, Store store) => store -> StreamName -> ExpectedVersion -> a -> m (Async EventNumber) Source #
Appends a single event at the end of a stream.
forEvents :: (MonadBase IO m, DecodeEvent a, Store store) => store -> StreamName -> (a -> m ()) -> ExceptT ForEventFailure m () Source #
Iterates over all events of stream given a starting point and a batch size.
forEventsWithNumber :: (MonadBase IO m, DecodeEvent a, Store store) => store -> StreamName -> (EventNumber -> a -> m ()) -> ExceptT ForEventFailure m () Source #
Iterates over all events of stream given a starting point and a batch size.
It also passes the EventNumber
at each recursion step.
foldEventsWithNumberM :: (MonadBase IO m, DecodeEvent a, Store store) => store -> StreamName -> (EventNumber -> s -> a -> m s) -> s -> ExceptT ForEventFailure m s Source #
Like forEvents
but expose signature similar to foldM
and also passes
the EventNumber
at each recursion step.
foldEventsM :: (MonadBase IO m, DecodeEvent a, Store store) => store -> StreamName -> (s -> a -> m s) -> s -> ExceptT ForEventFailure m s Source #
Like forEvents
but expose signature similar to foldM
.
foldEvents :: (MonadBase IO m, DecodeEvent a, Store store) => store -> StreamName -> (s -> a -> s) -> s -> ExceptT ForEventFailure m s Source #
Like foldEventsM
but expose signature similar to foldl
.
forSavedEvents :: (MonadBase IO m, Store store) => store -> StreamName -> (SavedEvent -> m ()) -> ExceptT ForEventFailure m () Source #
Like forEvents
but provides access to SavedEvent
instead of
decoded event.
foldSavedEventsM :: (MonadBase IO m, Store store) => store -> StreamName -> (s -> SavedEvent -> m s) -> s -> ExceptT ForEventFailure m s Source #
Like forSavedEvents
but expose signature similar to foldM
.
foldSavedEvents :: (MonadBase IO m, Store store) => store -> StreamName -> (s -> SavedEvent -> s) -> s -> ExceptT ForEventFailure m s Source #
Like foldSavedEventsM
but expose signature similar to foldl
.
foldSubSaved :: MonadBase IO m => Subscription -> (SavedEvent -> m ()) -> (SomeException -> m ()) -> m () Source #
Similar to foldSub
but provides access to the SavedEvent
instead of
decoded event.
foldSubSavedAsync :: MonadBaseControl IO m => Subscription -> (SavedEvent -> m ()) -> (SomeException -> m ()) -> m (Async (StM m ())) Source #
Asynchronous version of foldSubSaved
.
data ForEventFailure Source #
Represents failures that can occurs when using forEvents
.