Copyright | (C) 2014 Yorick Laupa |
---|---|
License | (see the file LICENSE) |
Maintainer | Yorick Laupa <[email protected]> |
Stability | provisional |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
Database.EventStore
Contents
Description
- data Connection
- data ConnectionException
- data ServerConnectionError
- data Credentials
- data Settings = Settings {}
- data Retry
- atMost :: Int -> Retry
- keepRetrying :: Retry
- credentials :: ByteString -> ByteString -> Credentials
- defaultSettings :: Settings
- connect :: Settings -> String -> Int -> IO Connection
- shutdown :: Connection -> IO ()
- waitTillClosed :: Connection -> IO ()
- data Event
- data EventData
- createEvent :: Text -> Maybe UUID -> EventData -> Event
- withJson :: ToJSON a => a -> EventData
- withJsonAndMetadata :: (ToJSON a, ToJSON b) => a -> b -> EventData
- data StreamMetadataResult
- readEvent :: Connection -> Text -> Int32 -> Bool -> IO (Async (ReadResult RegularStream ReadEvent))
- readAllEventsBackward :: Connection -> Position -> Int32 -> Bool -> IO (Async AllSlice)
- readAllEventsForward :: Connection -> Position -> Int32 -> Bool -> IO (Async AllSlice)
- readStreamEventsBackward :: Connection -> Text -> Int32 -> Int32 -> Bool -> IO (Async (ReadResult RegularStream StreamSlice))
- readStreamEventsForward :: Connection -> Text -> Int32 -> Int32 -> Bool -> IO (Async (ReadResult RegularStream StreamSlice))
- getStreamMetadata :: Connection -> Text -> IO (Async StreamMetadataResult)
- data StreamACL = StreamACL {
- streamACLReadRoles :: ![Text]
- streamACLWriteRoles :: ![Text]
- streamACLDeleteRoles :: ![Text]
- streamACLMetaReadRoles :: ![Text]
- streamACLMetaWriteRoles :: ![Text]
- data StreamMetadata = StreamMetadata {}
- getCustomPropertyValue :: StreamMetadata -> Text -> Maybe Value
- getCustomProperty :: FromJSON a => StreamMetadata -> Text -> Maybe a
- emptyStreamACL :: StreamACL
- emptyStreamMetadata :: StreamMetadata
- deleteStream :: Connection -> Text -> ExpectedVersion -> Maybe Bool -> IO (Async DeleteResult)
- sendEvent :: Connection -> Text -> ExpectedVersion -> Event -> IO (Async WriteResult)
- sendEvents :: Connection -> Text -> ExpectedVersion -> [Event] -> IO (Async WriteResult)
- setStreamMetadata :: Connection -> Text -> ExpectedVersion -> StreamMetadata -> IO (Async WriteResult)
- type Builder a = Endo a
- type StreamACLBuilder = Builder StreamACL
- buildStreamACL :: StreamACLBuilder -> StreamACL
- modifyStreamACL :: StreamACLBuilder -> StreamACL -> StreamACL
- setReadRoles :: [Text] -> StreamACLBuilder
- setReadRole :: Text -> StreamACLBuilder
- setWriteRoles :: [Text] -> StreamACLBuilder
- setWriteRole :: Text -> StreamACLBuilder
- setDeleteRoles :: [Text] -> StreamACLBuilder
- setDeleteRole :: Text -> StreamACLBuilder
- setMetaReadRoles :: [Text] -> StreamACLBuilder
- setMetaReadRole :: Text -> StreamACLBuilder
- setMetaWriteRoles :: [Text] -> StreamACLBuilder
- setMetaWriteRole :: Text -> StreamACLBuilder
- type StreamMetadataBuilder = Builder StreamMetadata
- buildStreamMetadata :: StreamMetadataBuilder -> StreamMetadata
- modifyStreamMetadata :: StreamMetadataBuilder -> StreamMetadata -> StreamMetadata
- setMaxCount :: Int32 -> StreamMetadataBuilder
- setMaxAge :: TimeSpan -> StreamMetadataBuilder
- setTruncateBefore :: Int32 -> StreamMetadataBuilder
- setCacheControl :: TimeSpan -> StreamMetadataBuilder
- setACL :: StreamACL -> StreamMetadataBuilder
- modifyACL :: StreamACLBuilder -> StreamMetadataBuilder
- setCustomProperty :: ToJSON a => Text -> a -> StreamMetadataBuilder
- data TimeSpan
- timeSpanTicks :: Int64 -> TimeSpan
- timeSpanHoursMinsSecs :: Int64 -> Int64 -> Int64 -> TimeSpan
- timeSpanDaysHoursMinsSecs :: Int64 -> Int64 -> Int64 -> Int64 -> TimeSpan
- timeSpanDaysHoursMinsSecsMillis :: Int64 -> Int64 -> Int64 -> Int64 -> Int64 -> TimeSpan
- timeSpanGetTicks :: TimeSpan -> Int64
- timeSpanGetDays :: TimeSpan -> Int64
- timeSpanGetHours :: TimeSpan -> Int64
- timeSpanGetMinutes :: TimeSpan -> Int64
- timeSpanGetSeconds :: TimeSpan -> Int64
- timeSpanGetMillis :: TimeSpan -> Int64
- timeSpanFromSeconds :: Double -> TimeSpan
- timeSpanFromMinutes :: Double -> TimeSpan
- timeSpanFromHours :: Double -> TimeSpan
- timeSpanFromDays :: Double -> TimeSpan
- timeSpanTotalMillis :: TimeSpan -> Int64
- data Transaction
- data TransactionId
- startTransaction :: Connection -> Text -> ExpectedVersion -> IO (Async Transaction)
- transactionId :: Transaction -> TransactionId
- transactionCommit :: Transaction -> IO (Async WriteResult)
- transactionRollback :: Transaction -> IO ()
- transactionWrite :: Transaction -> [Event] -> IO (Async ())
- data SubscriptionClosed = SubscriptionClosed Running SubDropReason
- data SubscriptionId
- data Subscription a
- data Running
- data SubDropReason
- data Regular
- subscribe :: Connection -> Text -> Bool -> IO (Subscription Regular)
- subscribeToAll :: Connection -> Bool -> IO (Subscription Regular)
- getSubId :: Subscription a -> IO SubscriptionId
- getSubStream :: Subscription a -> Text
- isSubscribedToAll :: Subscription a -> Bool
- unsubscribe :: Subscription a -> IO ()
- nextEvent :: Subscription a -> IO ResolvedEvent
- nextEventMaybe :: Subscription a -> IO (Maybe ResolvedEvent)
- getSubResolveLinkTos :: Subscription Regular -> Bool
- getSubLastCommitPos :: Subscription a -> IO Int64
- getSubLastEventNumber :: Subscription a -> IO (Maybe Int32)
- data Catchup
- subscribeFrom :: Connection -> Text -> Bool -> Maybe Int32 -> Maybe Int32 -> IO (Subscription Catchup)
- subscribeToAllFrom :: Connection -> Bool -> Maybe Position -> Maybe Int32 -> IO (Subscription Catchup)
- waitTillCatchup :: Subscription Catchup -> IO ()
- hasCaughtUp :: Subscription Catchup -> IO Bool
- data Persistent
- data PersistentSubscriptionSettings = PersistentSubscriptionSettings {
- psSettingsResolveLinkTos :: !Bool
- psSettingsStartFrom :: !Int32
- psSettingsExtraStats :: !Bool
- psSettingsMsgTimeout :: !TimeSpan
- psSettingsMaxRetryCount :: !Int32
- psSettingsLiveBufSize :: !Int32
- psSettingsReadBatchSize :: !Int32
- psSettingsHistoryBufSize :: !Int32
- psSettingsCheckPointAfter :: !TimeSpan
- psSettingsMinCheckPointCount :: !Int32
- psSettingsMaxCheckPointCount :: !Int32
- psSettingsMaxSubsCount :: !Int32
- psSettingsNamedConsumerStrategy :: !SystemConsumerStrategy
- data SystemConsumerStrategy
- data NakAction
- = NA_Unknown
- | NA_Park
- | NA_Retry
- | NA_Skip
- | NA_Stop
- data PersistActionException
- acknowledge :: Subscription Persistent -> ResolvedEvent -> IO ()
- acknowledgeEvents :: Subscription Persistent -> [ResolvedEvent] -> IO ()
- failed :: Subscription Persistent -> ResolvedEvent -> NakAction -> Maybe Text -> IO ()
- eventsFailed :: Subscription Persistent -> [ResolvedEvent] -> NakAction -> Maybe Text -> IO ()
- notifyEventsProcessed :: Subscription Persistent -> [UUID] -> IO ()
- notifyEventsFailed :: Subscription Persistent -> NakAction -> Maybe Text -> [UUID] -> IO ()
- defaultPersistentSubscriptionSettings :: PersistentSubscriptionSettings
- createPersistentSubscription :: Connection -> Text -> Text -> PersistentSubscriptionSettings -> IO (Async (Maybe PersistActionException))
- updatePersistentSubscription :: Connection -> Text -> Text -> PersistentSubscriptionSettings -> IO (Async (Maybe PersistActionException))
- deletePersistentSubscription :: Connection -> Text -> Text -> IO (Async (Maybe PersistActionException))
- connectToPersistentSubscription :: Connection -> Text -> Text -> Int32 -> IO (Subscription Persistent)
- class Slice a where
- type Loc a
- sliceEvents :: a -> [ResolvedEvent]
- sliceDirection :: a -> ReadDirection
- sliceEOS :: a -> Bool
- sliceFrom :: a -> Loc a
- sliceNext :: a -> Loc a
- data AllSlice
- newtype DeleteResult = DeleteResult Position
- data WriteResult = WriteResult {}
- data ReadResult :: StreamType -> * -> * where
- ReadSuccess :: a -> ReadResult t a
- ReadNoStream :: ReadResult RegularStream a
- ReadStreamDeleted :: Text -> ReadResult RegularStream a
- ReadNotModified :: ReadResult t a
- ReadError :: Maybe Text -> ReadResult t a
- ReadAccessDenied :: StreamName -> ReadResult t a
- data RecordedEvent = RecordedEvent {}
- data ReadEvent
- = ReadEventNotFound {
- readEventStream :: !Text
- readEventNumber :: !Int32
- | ReadEvent { }
- = ReadEventNotFound {
- data StreamType
- = All
- | RegularStream
- data StreamSlice
- data Position = Position {
- positionCommit :: !Int64
- positionPrepare :: !Int64
- data ReadDirection
- data ResolvedEvent = ResolvedEvent {}
- data OperationError
- data StreamName
- isEventResolvedLink :: ResolvedEvent -> Bool
- resolvedEventOriginal :: ResolvedEvent -> RecordedEvent
- resolvedEventDataAsJson :: FromJSON a => ResolvedEvent -> Maybe a
- resolvedEventOriginalStreamId :: ResolvedEvent -> Text
- resolvedEventOriginalId :: ResolvedEvent -> UUID
- recordedEventDataAsJson :: FromJSON a => RecordedEvent -> Maybe a
- positionStart :: Position
- positionEnd :: Position
- data DropReason
- data ExpectedVersion
- anyVersion :: ExpectedVersion
- noStreamVersion :: ExpectedVersion
- emptyStreamVersion :: ExpectedVersion
- exactEventVersion :: Int32 -> ExpectedVersion
- module Control.Concurrent.Async
- (<>) :: Monoid m => m -> m -> m
Connection
data Connection Source
Represents a connection to a single EventStore node.
data ConnectionException Source
Type of connection issue that can arise during the communication with the server.
Constructors
MaxAttemptConnectionReached HostName Int Int | The max reconnection attempt threshold has been reached. Holds a
|
ClosedConnection | Use of a close |
data ServerConnectionError Source
Raised when the server responded in an unexpected way.
Constructors
WrongPackageFraming | TCP package sent by the server had a wrong framing. |
PackageParsingError String | Server sent a malformed TCP package. |
Global Connection
settings
Constructors
Settings | |
Fields
|
Indicates how many times we should try to reconnect to the server. A value less than or equal to 0 means no retry.
Indicates we should try to reconnect to the server until the end of the Universe.
Arguments
:: ByteString | Login |
-> ByteString | Password |
-> Credentials |
Creates a Credentials
given a login and a password.
defaultSettings :: Settings Source
Default global settings.
Arguments
:: Settings | |
-> String | HostName |
-> Int | Port |
-> IO Connection |
Creates a new Connection
to a single node. It maintains a full duplex
connection to the EventStore. An EventStore Connection
operates quite
differently than say a SQL connection. Normally when you use an EventStore
connection you want to keep the connection open for a much longer of time
than when you use a SQL connection.
Another difference is that with the EventStore Connection
all operations
are handled in a full async manner (even if you call the synchronous
behaviors). Many threads can use an EvenStore Connection
at the same time
or a single thread can make many asynchronous requests. To get the most
performance out of the connection it is generally recommended to use it in
this way.
shutdown :: Connection -> IO () Source
Asynchronously closes the Connection
.
waitTillClosed :: Connection -> IO () Source
Waits the Connection
to be closed.
Event
Contains event information like its type and data. Only used for write queries.
Create an Event
meant to be persisted.
withJsonAndMetadata :: (ToJSON a, ToJSON b) => a -> b -> EventData Source
Create a event with metadata using JSON format
Read Operations
data StreamMetadataResult Source
Represents stream metadata as a series of properties for system data and a
StreamMetadata
object for user metadata.
Constructors
StreamMetadataResult | |
Fields
| |
NotFoundStreamMetadataResult | When the stream is either not found or 'no stream'. |
Fields
| |
DeletedStreamMetadataResult | When the stream is soft-deleted. |
Fields
|
Instances
Arguments
:: Connection | |
-> Text | Stream name |
-> Int32 | Event number |
-> Bool | Resolve Link Tos |
-> IO (Async (ReadResult RegularStream ReadEvent)) |
Reads a single event from given stream.
Reads events from the $all stream backward
Reads events from the $all stream forward.
readStreamEventsBackward Source
Arguments
:: Connection | |
-> Text | Stream name |
-> Int32 | From event number |
-> Int32 | Batch size |
-> Bool | Resolve Link Tos |
-> IO (Async (ReadResult RegularStream StreamSlice)) |
Reads events from a given stream backward.
readStreamEventsForward Source
Arguments
:: Connection | |
-> Text | Stream name |
-> Int32 | From event number |
-> Int32 | Batch size |
-> Bool | Resolve Link Tos |
-> IO (Async (ReadResult RegularStream StreamSlice)) |
Reads events from a given stream forward.
getStreamMetadata :: Connection -> Text -> IO (Async StreamMetadataResult) Source
Asynchronously gets the metadata of a stream.
Write Operations
Represents an access control list for a stream.
Constructors
StreamACL | |
Fields
|
data StreamMetadata Source
Represents stream metadata with strongly typed properties for system values and a dictionary-like interface for custom values.
Constructors
StreamMetadata | |
Fields
|
getCustomPropertyValue :: StreamMetadata -> Text -> Maybe Value Source
Gets a custom property value from metadata.
getCustomProperty :: FromJSON a => StreamMetadata -> Text -> Maybe a Source
Get a custom property value from metadata.
emptyStreamACL :: StreamACL Source
StreamACL
with no role or users whatsoever.
emptyStreamMetadata :: StreamMetadata Source
StreamMetadata
with everything set to Nothing
, using emptyStreamACL
and an empty Object
.
Arguments
:: Connection | |
-> Text | Stream name |
-> ExpectedVersion | |
-> Maybe Bool | Hard delete |
-> IO (Async DeleteResult) |
Deletes given stream.
Arguments
:: Connection | |
-> Text | Stream name |
-> ExpectedVersion | |
-> Event | |
-> IO (Async WriteResult) |
Sends a single Event
to given stream.
Arguments
:: Connection | |
-> Text | Stream name |
-> ExpectedVersion | |
-> [Event] | |
-> IO (Async WriteResult) |
Sends a list of Event
to given stream.
setStreamMetadata :: Connection -> Text -> ExpectedVersion -> StreamMetadata -> IO (Async WriteResult) Source
Asynchronously sets the metadata for a stream.
Builder
Stream ACL Builder
buildStreamACL :: StreamACLBuilder -> StreamACL Source
Builds a StreamACL
from a StreamACLBuilder
.
modifyStreamACL :: StreamACLBuilder -> StreamACL -> StreamACL Source
Modifies a StreamACL
using a StreamACLBuilder
.
setReadRoles :: [Text] -> StreamACLBuilder Source
Sets role names with read permission for the stream.
setReadRole :: Text -> StreamACLBuilder Source
Sets a single role name with read permission for the stream.
setWriteRoles :: [Text] -> StreamACLBuilder Source
Sets role names with write permission for the stream.
setWriteRole :: Text -> StreamACLBuilder Source
Sets a single role name with write permission for the stream.
setDeleteRoles :: [Text] -> StreamACLBuilder Source
Sets role names with delete permission for the stream.
setDeleteRole :: Text -> StreamACLBuilder Source
Sets a single role name with delete permission for the stream.
setMetaReadRoles :: [Text] -> StreamACLBuilder Source
Sets role names with metadata read permission for the stream.
setMetaReadRole :: Text -> StreamACLBuilder Source
Sets a single role name with metadata read permission for the stream.
setMetaWriteRoles :: [Text] -> StreamACLBuilder Source
Sets role names with metadata write permission for the stream.
setMetaWriteRole :: Text -> StreamACLBuilder Source
Sets a single role name with metadata write permission for the stream.
Stream Metadata Builder
type StreamMetadataBuilder = Builder StreamMetadata Source
A Builder
applies to StreamMetadata
.
buildStreamMetadata :: StreamMetadataBuilder -> StreamMetadata Source
Builds a StreamMetadata
from a StreamMetadataBuilder
.
modifyStreamMetadata :: StreamMetadataBuilder -> StreamMetadata -> StreamMetadata Source
Modifies a StreamMetadata
using a StreamMetadataBuilder
setMaxCount :: Int32 -> StreamMetadataBuilder Source
Sets the maximum number of events allowed in the stream.
setMaxAge :: TimeSpan -> StreamMetadataBuilder Source
Sets the maximum age of events allowed in the stream.
setTruncateBefore :: Int32 -> StreamMetadataBuilder Source
Sets the event number from which previous events can be scavenged.
setCacheControl :: TimeSpan -> StreamMetadataBuilder Source
Sets the amount of time for which the stream head is cachable.
setACL :: StreamACL -> StreamMetadataBuilder Source
Overwrites any previous StreamACL
by the given one in a
StreamMetadataBuilder
.
modifyACL :: StreamACLBuilder -> StreamMetadataBuilder Source
Updates a StreamMetadata'
s StreamACL
given a StreamACLBuilder
.
setCustomProperty :: ToJSON a => Text -> a -> StreamMetadataBuilder Source
Sets a custom metadata property.
TimeSpan
.NET TimeSpan: Represents a time interval.
timeSpanTicks :: Int64 -> TimeSpan Source
Initializes a new instance of the TimeSpan structure to the specified number of ticks.
timeSpanHoursMinsSecs :: Int64 -> Int64 -> Int64 -> TimeSpan Source
Initializes a new instance of the TimeSpan structure to a specified number of hours, minutes, and seconds.
timeSpanDaysHoursMinsSecs :: Int64 -> Int64 -> Int64 -> Int64 -> TimeSpan Source
Initializes a new instance of the TimeSpan structure to a specified number of days, hours, minutes, and seconds.
timeSpanDaysHoursMinsSecsMillis :: Int64 -> Int64 -> Int64 -> Int64 -> Int64 -> TimeSpan Source
Initializes a new instance of the TimeSpan structure to a specified number of days, hours, minutes, seconds, and milliseconds.
timeSpanGetTicks :: TimeSpan -> Int64 Source
Gets the number of ticks that represent the value of the current TimeSpan
structure.
timeSpanGetDays :: TimeSpan -> Int64 Source
Gets the days component of the time interval represented by the current
TimeSpan
structure.
timeSpanGetHours :: TimeSpan -> Int64 Source
Gets the hours component of the time interval represented by the current
TimeSpan
structure.
timeSpanGetMinutes :: TimeSpan -> Int64 Source
Gets the minutes component of the time interval represented by the current
TimeSpan
structure.
timeSpanGetSeconds :: TimeSpan -> Int64 Source
Gets the seconds component of the time interval represented by the current
TimeSpan
structure.
timeSpanGetMillis :: TimeSpan -> Int64 Source
Gets the milliseconds component of the time interval represented by the
current TimeSpan
structure.
timeSpanFromSeconds :: Double -> TimeSpan Source
Returns a TimeSpan
that represents a specified number of seconds, where
the specification is accurate to the nearest millisecond.
timeSpanFromMinutes :: Double -> TimeSpan Source
Returns a TimeSpan
that represents a specified number of minutes, where
the specification is accurate to the nearest millisecond.
timeSpanFromHours :: Double -> TimeSpan Source
Returns a TimeSpan
that represents a specified number of hours, where the
specification is accurate to the nearest millisecond.
timeSpanFromDays :: Double -> TimeSpan Source
Returns a TimeSpan
that represents a specified number of days, where the
specification is accurate to the nearest millisecond.
timeSpanTotalMillis :: TimeSpan -> Int64 Source
Gets the value of the current TimeSpan
structure expressed in whole and
fractional milliseconds.
Transaction
data Transaction Source
Represents a multi-request transaction with the EventStore.
Arguments
:: Connection | |
-> Text | Stream name |
-> ExpectedVersion | |
-> IO (Async Transaction) |
Starts a transaction on given stream.
transactionId :: Transaction -> TransactionId Source
Gets the id of a Transaction
.
transactionCommit :: Transaction -> IO (Async WriteResult) Source
Asynchronously commits this transaction.
transactionRollback :: Transaction -> IO () Source
There isn't such of thing in EventStore parlance. Basically, if you want to
rollback, you just have to not transactionCommit
a Transaction
.
transactionWrite :: Transaction -> [Event] -> IO (Async ()) Source
Asynchronously writes to a transaction in the EventStore.
Subscription
data SubscriptionClosed Source
This exception is raised when the user tries to get the next event from a
Subscription
that is already closed.
Constructors
SubscriptionClosed Running SubDropReason |
data SubscriptionId Source
Represents a subscription id.
data Subscription a Source
It's possible to subscribe to a stream and be notified when new events are written to that stream. There are three types of subscription which are available, all of which can be useful in different situations.
Represents a running subscription. Gathers useful information.
Constructors
RunningReg UUID Text Bool Int64 (Maybe Int32) | Related regular subscription. In order of appearance:
|
RunningPersist UUID Text Text Int32 Text Int64 (Maybe Int32) | Related to persistent subscription. In order of appearance:
|
data SubDropReason Source
Indicates why a subscription has been dropped.
Constructors
SubUnsubscribed | Subscription connection has been closed by the user. |
SubAccessDenied | The current user is not allowed to operate on the supplied stream. |
SubNotFound | Given stream name doesn't exist. |
SubPersistDeleted | Given stream is deleted. |
SubAborted | Occurs when the user shutdown the connection from the server or if the connection to the server is no longer possible. |
Instances
Volatile Subscription
Also referred as volatile subscription. For example, if a stream has 100 events in it when a subscriber connects, the subscriber can expect to see event number 101 onwards until the time the subscription is closed or dropped.
Arguments
:: Connection | |
-> Text | Stream name |
-> Bool | Resolve Link Tos |
-> IO (Subscription Regular) |
Subcribes to given stream.
Arguments
:: Connection | |
-> Bool | Resolve Link Tos |
-> IO (Subscription Regular) |
Subcribes to $all stream.
getSubId :: Subscription a -> IO SubscriptionId Source
Gets the ID of the subscription.
getSubStream :: Subscription a -> Text Source
Gets the subscription stream name.
isSubscribedToAll :: Subscription a -> Bool Source
If the subscription is on the $all stream.
unsubscribe :: Subscription a -> IO () Source
Asynchronously unsubscribe from the the stream.
nextEvent :: Subscription a -> IO ResolvedEvent Source
Awaits for the next event.
nextEventMaybe :: Subscription a -> IO (Maybe ResolvedEvent) Source
Non blocking version of nextEvent
.
getSubResolveLinkTos :: Subscription Regular -> Bool Source
Determines whether or not any link events encontered in the stream will be resolved.
getSubLastCommitPos :: Subscription a -> IO Int64 Source
The last commit position seen on the subscription (if this a subscription to $all stream).
getSubLastEventNumber :: Subscription a -> IO (Maybe Int32) Source
The last event number seen on the subscription (if this is a subscription to a single stream).
Catch-up Subscription
This kind of subscription specifies a starting point, in the form of an event number or transaction file position. The given function will be called for events from the starting point until the end of the stream, and then for subsequently written events.
For example, if a starting point of 50 is specified when a stream has 100 events in it, the subscriber can expect to see events 51 through 100, and then any events subsequently written until such time as the subscription is dropped or closed.
Arguments
:: Connection | |
-> Text | Stream name |
-> Bool | Resolve Link Tos |
-> Maybe Int32 | Last checkpoint |
-> Maybe Int32 | Batch size |
-> IO (Subscription Catchup) |
Subscribes to given stream. If last checkpoint is defined, this will
readStreamEventsForward
from that event number, otherwise from the
beginning. Once last stream event reached up, a subscription request will
be sent using subscribe
.
Arguments
:: Connection | |
-> Bool | Resolve Link Tos |
-> Maybe Position | Last checkpoint |
-> Maybe Int32 | Batch size |
-> IO (Subscription Catchup) |
Same as subscribeFrom
but applied to $all stream.
waitTillCatchup :: Subscription Catchup -> IO () Source
Waits until CatchupSubscription
subscription catch-up its stream.
hasCaughtUp :: Subscription Catchup -> IO Bool Source
Non blocking version of waitTillCatchup
.
Persistent Subscription
data Persistent Source
The server remembers the state of the subscription. This allows for many different modes of operations compared to a regular or catchup subscription where the client holds the subscription state. (Need EventStore >= v3.1.0).
data PersistentSubscriptionSettings Source
Gathers every persistent subscription property.
Constructors
PersistentSubscriptionSettings | |
Fields
|
data SystemConsumerStrategy Source
System supported consumer strategies for use with persistent subscriptions.
Constructors
DispatchToSingle | Distributes events to a single client until it is full. Then round robin to the next client. |
RoundRobin | Distributes events to each client in a round robin fashion. |
Gathers every possible Nak actions.
Constructors
NA_Unknown | |
NA_Park | |
NA_Retry | |
NA_Skip | |
NA_Stop |
data PersistActionException Source
Enumerates all persistent action exceptions.
Constructors
PersistActionFail | The action failed. |
PersistActionAlreadyExist | Happens when creating a persistent subscription on a stream with a group name already taken. |
PersistActionDoesNotExist | An operation tried to do something on a persistent subscription or a stream that don't exist. |
PersistActionAccessDenied | The current user is not allowed to operate on the supplied stream or persistent subscription. |
PersistActionAborted | That action has been aborted because the user shutdown the connection to the server or the connection to the server is no longer possible. |
acknowledge :: Subscription Persistent -> ResolvedEvent -> IO () Source
Acknowledges that ResolvedEvent
has been successfully processed.
acknowledgeEvents :: Subscription Persistent -> [ResolvedEvent] -> IO () Source
Acknowledges those ResolvedEvent
s have been successfully processed.
failed :: Subscription Persistent -> ResolvedEvent -> NakAction -> Maybe Text -> IO () Source
Mark a message that has failed processing. The server will take action based upon the action parameter.
eventsFailed :: Subscription Persistent -> [ResolvedEvent] -> NakAction -> Maybe Text -> IO () Source
Mark messages that have failed processing. The server will take action based upon the action parameter.
notifyEventsProcessed :: Subscription Persistent -> [UUID] -> IO () Source
Acknowledges those event ids have been successfully processed.
notifyEventsFailed :: Subscription Persistent -> NakAction -> Maybe Text -> [UUID] -> IO () Source
Acknowledges those event ids have failed to be processed successfully.
defaultPersistentSubscriptionSettings :: PersistentSubscriptionSettings Source
System default persistent subscription settings.
createPersistentSubscription :: Connection -> Text -> Text -> PersistentSubscriptionSettings -> IO (Async (Maybe PersistActionException)) Source
Asynchronously create a persistent subscription group on a stream.
updatePersistentSubscription :: Connection -> Text -> Text -> PersistentSubscriptionSettings -> IO (Async (Maybe PersistActionException)) Source
Asynchronously update a persistent subscription group on a stream.
deletePersistentSubscription :: Connection -> Text -> Text -> IO (Async (Maybe PersistActionException)) Source
Asynchronously delete a persistent subscription group on a stream.
connectToPersistentSubscription :: Connection -> Text -> Text -> Int32 -> IO (Subscription Persistent) Source
Asynchronously connect to a persistent subscription given a group on a stream.
Results
Gathers common slice operations.
Methods
sliceEvents :: a -> [ResolvedEvent] Source
Gets slice's ResolvedEvent
s.
sliceDirection :: a -> ReadDirection Source
Gets slice's reading direction.
If the slice reaches the end of the stream.
sliceFrom :: a -> Loc a Source
Gets the starting location of this slice.
sliceNext :: a -> Loc a Source
Gets the next location of this slice.
Represents a slice of the $all stream.
newtype DeleteResult Source
Returned after deleting a stream. Position
of the write.
Constructors
DeleteResult Position |
Instances
data WriteResult Source
Returned after writing to a stream.
Constructors
WriteResult | |
Fields
|
Instances
data ReadResult :: StreamType -> * -> * where Source
Enumeration detailing the possible outcomes of reading a stream.
Constructors
ReadSuccess :: a -> ReadResult t a | |
ReadNoStream :: ReadResult RegularStream a | |
ReadStreamDeleted :: Text -> ReadResult RegularStream a | |
ReadNotModified :: ReadResult t a | |
ReadError :: Maybe Text -> ReadResult t a | |
ReadAccessDenied :: StreamName -> ReadResult t a |
Instances
Functor (ReadResult t) Source | |
Foldable (ReadResult t) Source | |
Traversable (ReadResult t) Source | |
Eq a => Eq (ReadResult t a) Source | |
Show a => Show (ReadResult t a) Source |
data RecordedEvent Source
Represents a previously written event.
Constructors
RecordedEvent | |
Fields
|
Instances
Represents the result of looking up a specific event number from a stream.
Constructors
ReadEventNotFound | |
Fields
| |
ReadEvent | |
Fields |
data StreamType Source
A stream can either point to $all or a regular one.
Constructors
All | |
RegularStream |
Instances
A structure referring to a potential logical record position in the EventStore transaction file.
Constructors
Position | |
Fields
|
data ReadDirection Source
Represents the direction of read operation (both from $all an usual streams).
Instances
data ResolvedEvent Source
A structure representing a single event or an resolved link event.
Constructors
ResolvedEvent | |
Fields
|
Instances
data OperationError Source
Operation exception that can occurs on an operation response.
Constructors
WrongExpectedVersion Text ExpectedVersion | Stream and Expected Version |
StreamDeleted Text | Stream |
InvalidTransaction | |
AccessDenied StreamName | Stream |
InvalidServerResponse Word8 Word8 | Expected, Found |
ProtobufDecodingError String | |
ServerError (Maybe Text) | Reason |
InvalidOperation Text | Invalid operation state. If happens, it's a driver bug. |
Aborted | Occurs when the user asked to close the connection or if the connection can't reconnect anymore. |
Instances
data StreamName Source
Represents a regular stream name or $all stream.
Constructors
StreamName Text | |
AllStream |
Instances
isEventResolvedLink :: ResolvedEvent -> Bool Source
Indicates whether this ResolvedEvent
is a resolved link event.
resolvedEventOriginal :: ResolvedEvent -> RecordedEvent Source
Returns the event that was read or which triggered the subscription.
If this ResolvedEvent
represents a link event, the link will be the
original event, otherwise it will be the event.
resolvedEventDataAsJson :: FromJSON a => ResolvedEvent -> Maybe a Source
Tries to desarialize resolvedEventOriginal
data as JSON.
resolvedEventOriginalStreamId :: ResolvedEvent -> Text Source
The stream name of the original event.
resolvedEventOriginalId :: ResolvedEvent -> UUID Source
The ID of the original event.
recordedEventDataAsJson :: FromJSON a => RecordedEvent -> Maybe a Source
Tries to parse JSON object from the given RecordedEvent
.
positionStart :: Position Source
Representing the start of the transaction file.
positionEnd :: Position Source
Representing the end of the transaction file.
Misc
data ExpectedVersion Source
Constants used for expected version control.
The use of expected version can be a bit tricky especially when discussing idempotency assurances given by the EventStore.
The EventStore will assure idempotency for all operations using any value
in ExpectedVersion
except for anyStream
. When using anyStream
the
EventStore will do its best to assure idempotency but will not guarantee
idempotency.
Instances
anyVersion :: ExpectedVersion Source
This write should not conflict with anything and should always succeed.
noStreamVersion :: ExpectedVersion Source
The stream being written to should not yet exist. If it does exist treat that as a concurrency problem.
emptyStreamVersion :: ExpectedVersion Source
The stream should exist and should be empty. If it does not exist or is not empty, treat that as a concurrency problem.
exactEventVersion :: Int32 -> ExpectedVersion Source
States that the last event written to the stream should have a sequence number matching your expected value.
Re-export
module Control.Concurrent.Async