| 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 |
EventSource.Types
Description
- data Data
- newtype JsonParsing a = JsonParsing (Value -> Parser a)
- dataAsBytes :: Data -> ByteString
- dataFromBytes :: ByteString -> Data
- dataFromJson :: ToJSON a => a -> Data
- dataAsJson :: FromJSON a => Data -> Either Text a
- dataAsParsing :: Data -> JsonParsing a -> Either Text a
- dataAsParse :: Data -> (Value -> Parser a) -> Either Text a
- newtype Properties = Properties (Map Text Text)
- property :: MonadPlus m => Text -> Properties -> m Text
- singleton :: Text -> Text -> Properties
- setProperty :: Text -> Text -> Properties -> Properties
- properties :: Properties -> [(Text, Text)]
- newtype EventId = EventId UUID
- freshEventId :: MonadIO m => m EventId
- newtype StreamName = StreamName Text
- newtype EventType = EventType Text
- setEventType :: EventType -> State Event ()
- setEventId :: EventId -> State Event ()
- setEventPayload :: Data -> State Event ()
- setEventMetadata :: Properties -> State Event ()
- data Event = Event {}
- newtype EventNumber = EventNumber Int32
- data SavedEvent = SavedEvent {}
- savedEventAs :: DecodeEvent a => SavedEvent -> Either Text a
- data Slice = Slice {}
- sliceEventsAs :: DecodeEvent a => Slice -> Either Text [a]
- class EncodeEvent a where
- class DecodeEvent a where
- newtype DecodeEventException = DecodeEventException Text
- data ExpectedVersion
- data ReadStatus a
- isReadSuccess :: ReadStatus a -> Bool
- isReadFailure :: ReadStatus a -> Bool
- data ReadFailure
Documentation
Opaque data type used to store raw data.
Constructors
| Data ByteString | |
| DataAsJson Value |
newtype JsonParsing a Source #
Sometimes, having to implement a FromJSON instance isn't flexible enough.
JsonParsing allow to pass parameters when parsing from a JSON value while
remaining composable.
Constructors
| JsonParsing (Value -> Parser a) |
Instances
dataAsBytes :: Data -> ByteString Source #
Returns Data content as a ByteString.
dataFromBytes :: ByteString -> Data Source #
Creates a Data object from a raw ByteString.
dataAsParsing :: Data -> JsonParsing a -> Either Text a Source #
Uses a JsonParsing comuputation to extract a value.
dataAsParse :: Data -> (Value -> Parser a) -> Either Text a Source #
Like dataAsParsing but doesn't require you to use JsonParsing.
newtype Properties Source #
Used to store a set a properties. One example is to be used as Event
metadata.
Constructors
| Properties (Map Text Text) |
Instances
property :: MonadPlus m => Text -> Properties -> m Text Source #
Retrieves a value associated with the given key.
singleton :: Text -> Text -> Properties Source #
Builds a Properties with a single pair of key-value.
setProperty :: Text -> Text -> Properties -> Properties Source #
Adds a pair of key-value into given Properties.
properties :: Properties -> [(Text, Text)] Source #
Returns all associated key-value pairs as a list.
Used to identify an event.
Used to identity the type of an Event.
setEventMetadata :: Properties -> State Event () Source #
Sets metadata for an Event.
Encapsulates an event which is about to be saved.
Constructors
| Event | |
Fields
| |
newtype EventNumber Source #
Represents an event index in a stream.
Constructors
| EventNumber Int32 |
Instances
data SavedEvent Source #
Represents an event that's saved into the event store.
Constructors
| SavedEvent | |
Fields | |
Instances
savedEventAs :: DecodeEvent a => SavedEvent -> Either Text a Source #
Deserializes a SavedEvent.
Represents batch of events read from a store.
Constructors
| Slice | |
Fields | |
sliceEventsAs :: DecodeEvent a => Slice -> Either Text [a] Source #
Deserializes a Slice's events.
class EncodeEvent a where Source #
Encodes a data object into an Event. encodeEvent get passed an
EventId in a case where a fresh id is needed.
Minimal complete definition
Methods
encodeEvent :: a -> State Event () Source #
class DecodeEvent a where Source #
Decodes an Event into a data object.
Minimal complete definition
Instances
data ExpectedVersion Source #
The purpose of ExpectedVersion is to make sure a certain stream state is
at an expected point in order to carry out a write.
Constructors
| AnyVersion | |
| NoStream | |
| StreamExists | |
| ExactVersion EventNumber |
Instances
data ReadStatus a Source #
Statuses you can get on every read attempt.
Constructors
| ReadSuccess a | |
| ReadFailure ReadFailure |
Instances
isReadSuccess :: ReadStatus a -> Bool Source #
Returns True is ReadStatus is a ReadSuccess.
isReadFailure :: ReadStatus a -> Bool Source #
Returns False is ReadStatus is a ReadFailure.
data ReadFailure Source #
Represents the different kind of failure you can get when reading.
Constructors
| StreamNotFound | |
| ReadError (Maybe Text) | |
| AccessDenied |
Instances