Copyright | (C) 2016 Yorick Laupa |
---|---|
License | (see the file LICENSE) |
Maintainer | Yorick Laupa <[email protected]> |
Stability | provisional |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
EventSource.Store
Description
- data Batch = Batch {}
- data Subscription = Subscription {
- subscriptionId :: SubscriptionId
- nextEvent :: forall m. MonadIO 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. MonadIO m => m (Maybe SavedEvent)
- iteratorNextEvent :: (DecodeEvent a, MonadIO m, MonadPlus m) => StreamIterator -> m (Maybe a)
- iteratorReadAll :: MonadIO m => StreamIterator -> m [SavedEvent]
- iteratorReadAllEvents :: (DecodeEvent a, MonadIO m, MonadPlus m) => StreamIterator -> m [a]
- streamIterator :: (Store store, MonadIO m) => store -> StreamName -> m (ReadStatus StreamIterator)
- freshSubscriptionId :: MonadIO m => m SubscriptionId
- startFrom :: EventNumber -> Batch
- nextEventAs :: (DecodeEvent a, MonadIO m) => Subscription -> m (Either SomeException a)
- foldSub :: (DecodeEvent a, MonadIO m) => Subscription -> (a -> m ()) -> (SomeException -> m ()) -> m ()
- foldSubAsync :: DecodeEvent a => Subscription -> (a -> IO ()) -> (SomeException -> IO ()) -> IO (Async ())
- appendEvent :: (EncodeEvent a, MonadIO m, Store store) => store -> StreamName -> ExpectedVersion -> a -> m (Async EventNumber)
- forEvents :: (MonadIO m, DecodeEvent a, Store store) => store -> StreamName -> (a -> m ()) -> ExceptT ForEventFailure m ()
- foldEventsM :: (MonadIO m, DecodeEvent a, Store store) => store -> StreamName -> (s -> a -> m s) -> s -> ExceptT ForEventFailure m s
- foldEvents :: (MonadIO m, DecodeEvent a, Store store) => store -> StreamName -> (s -> a -> s) -> s -> ExceptT ForEventFailure m s
Documentation
Represents batch information needed to read a stream.
Constructors
Batch | |
Fields
|
data Subscription Source #
A subscription allows to be notified on every change occuring on a stream.
Constructors
Subscription | |
Fields
|
data ExpectedVersionException Source #
Constructors
ExpectedVersionException | |
class Store store where Source #
Main event store abstraction. It exposes essential features expected from an event store.
Minimal complete definition
Methods
appendEvents :: (EncodeEvent a, MonadIO m) => store -> StreamName -> ExpectedVersion -> [a] -> m (Async EventNumber) Source #
Appends a batch of events at the end of a stream.
readBatch :: MonadIO m => store -> StreamName -> Batch -> m (Async (ReadStatus Slice)) Source #
Appends a batch of events at the end of a stream.
subscribe :: MonadIO m => store -> StreamName -> m Subscription Source #
Subscribes to given stream.
Utility type to pass any store that implements Store
typeclass.
iteratorNext :: StreamIterator -> forall m. MonadIO m => m (Maybe SavedEvent) Source #
iteratorNextEvent :: (DecodeEvent a, MonadIO 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 :: MonadIO m => StreamIterator -> m [SavedEvent] Source #
Reads all events from the StreamIterator
until reaching end of stream.
iteratorReadAllEvents :: (DecodeEvent a, MonadIO m, MonadPlus m) => StreamIterator -> m [a] Source #
Like iteratorReadAll
but try to deserialize the events at the same time.
streamIterator :: (Store store, MonadIO m) => store -> StreamName -> m (ReadStatus StreamIterator) Source #
Returns a StreamIterator
for the given stream name. The returned
StreamIterator
IS NOT THREADSAFE.
freshSubscriptionId :: MonadIO 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, MonadIO m) => Subscription -> m (Either SomeException a) Source #
Waits for the next event and deserializes it on the go.
foldSub :: (DecodeEvent a, MonadIO 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 :: DecodeEvent a => Subscription -> (a -> IO ()) -> (SomeException -> IO ()) -> IO (Async ()) Source #
Asynchronous version of foldSub
.
appendEvent :: (EncodeEvent a, MonadIO m, Store store) => store -> StreamName -> ExpectedVersion -> a -> m (Async EventNumber) Source #
Appends a single event at the end of a stream.
forEvents :: (MonadIO 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.
foldEventsM :: (MonadIO m, DecodeEvent a, Store store) => store -> StreamName -> (s -> a -> m s) -> s -> ExceptT ForEventFailure m s Source #
foldEvents :: (MonadIO m, DecodeEvent a, Store store) => store -> StreamName -> (s -> a -> s) -> s -> ExceptT ForEventFailure m s Source #
Like foldEventsM
but expose signature similar to foldl
.