eventsource-api-1.5.0: Provides an eventsourcing high level API.

Copyright(C) 2016 Yorick Laupa
License(see the file LICENSE)
MaintainerYorick Laupa <yo.eight@gmail.com>
Stabilityprovisional
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

EventSource.Types

Description

 
Synopsis

Documentation

data Data Source #

Opaque data type used to store raw data.

Instances
Show Data Source # 
Instance details

Defined in EventSource.Types

Methods

showsPrec :: Int -> Data -> ShowS #

show :: Data -> String #

showList :: [Data] -> ShowS #

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
Monad JsonParsing Source # 
Instance details

Defined in EventSource.Types

Functor JsonParsing Source # 
Instance details

Defined in EventSource.Types

Methods

fmap :: (a -> b) -> JsonParsing a -> JsonParsing b #

(<$) :: a -> JsonParsing b -> JsonParsing a #

Applicative JsonParsing Source # 
Instance details

Defined in EventSource.Types

Methods

pure :: a -> JsonParsing a #

(<*>) :: JsonParsing (a -> b) -> JsonParsing a -> JsonParsing b #

liftA2 :: (a -> b -> c) -> JsonParsing a -> JsonParsing b -> JsonParsing c #

(*>) :: JsonParsing a -> JsonParsing b -> JsonParsing b #

(<*) :: JsonParsing a -> JsonParsing b -> JsonParsing a #

dataAsBytes :: Data -> ByteString Source #

Returns Data content as a ByteString.

dataFromBytes :: ByteString -> Data Source #

Creates a Data object from a raw ByteString.

dataFromJson :: ToJSON a => a -> Data Source #

Creates a Data object from a JSON object.

dataAsJson :: FromJSON a => Data -> Either Text a Source #

Returns Data content as any value that implements FromJSON type-class.

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) 

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.

newtype EventId Source #

Used to identify an event.

Constructors

EventId UUID 
Instances
Eq EventId Source # 
Instance details

Defined in EventSource.Types

Methods

(==) :: EventId -> EventId -> Bool #

(/=) :: EventId -> EventId -> Bool #

Ord EventId Source # 
Instance details

Defined in EventSource.Types

Show EventId Source # 
Instance details

Defined in EventSource.Types

ToJSON EventId Source # 
Instance details

Defined in EventSource.Types

FromJSON EventId Source # 
Instance details

Defined in EventSource.Types

freshEventId :: MonadBase IO m => m EventId Source #

Generates a fresh EventId.

newtype EventType Source #

Used to identity the type of an Event.

Constructors

EventType Text 
Instances
Eq EventType Source # 
Instance details

Defined in EventSource.Types

Show EventType Source # 
Instance details

Defined in EventSource.Types

IsString EventType Source # 
Instance details

Defined in EventSource.Types

ToJSON EventType Source # 
Instance details

Defined in EventSource.Types

FromJSON EventType Source # 
Instance details

Defined in EventSource.Types

setEventId :: EventId -> State Event () Source #

Sets Eventid for an Event.

setEventPayload :: Data -> State Event () Source #

Sets a payload for an Event.

setEventMetadata :: Properties -> State Event () Source #

Sets metadata for an Event.

data Event Source #

Encapsulates an event which is about to be saved.

Instances
Show Event Source # 
Instance details

Defined in EventSource.Types

Methods

showsPrec :: Int -> Event -> ShowS #

show :: Event -> String #

showList :: [Event] -> ShowS #

DecodeEvent Event Source # 
Instance details

Defined in EventSource.Types

EncodeEvent Event Source # 
Instance details

Defined in EventSource.Types

newtype EventNumber Source #

Represents an event index in a stream.

Constructors

EventNumber Int64 
Instances
Enum EventNumber Source # 
Instance details

Defined in EventSource.Types

Eq EventNumber Source # 
Instance details

Defined in EventSource.Types

Num EventNumber Source # 
Instance details

Defined in EventSource.Types

Ord EventNumber Source # 
Instance details

Defined in EventSource.Types

Show EventNumber Source # 
Instance details

Defined in EventSource.Types

ToJSON EventNumber Source # 
Instance details

Defined in EventSource.Types

FromJSON EventNumber Source # 
Instance details

Defined in EventSource.Types

data SavedEvent Source #

Represents an event that's saved into the event store.

Constructors

SavedEvent 
Instances
Show SavedEvent Source # 
Instance details

Defined in EventSource.Types

data Slice' a Source #

Represents batch of events read from a store.

Constructors

Slice' 
Instances
Show a => Show (Slice' a) Source # 
Instance details

Defined in EventSource.Types

Methods

showsPrec :: Int -> Slice' a -> ShowS #

show :: Slice' a -> String #

showList :: [Slice' a] -> ShowS #

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.

Methods

encodeEvent :: a -> State Event () Source #

Instances
EncodeEvent Event Source # 
Instance details

Defined in EventSource.Types

class DecodeEvent a where Source #

Decodes an Event into a data object.

Instances
DecodeEvent Event Source # 
Instance details

Defined in EventSource.Types

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.

data ReadStatus a Source #

Statuses you can get on every read attempt.

Instances
Functor ReadStatus Source # 
Instance details

Defined in EventSource.Types

Methods

fmap :: (a -> b) -> ReadStatus a -> ReadStatus b #

(<$) :: a -> ReadStatus b -> ReadStatus a #

Foldable ReadStatus Source # 
Instance details

Defined in EventSource.Types

Methods

fold :: Monoid m => ReadStatus m -> m #

foldMap :: Monoid m => (a -> m) -> ReadStatus a -> m #

foldr :: (a -> b -> b) -> b -> ReadStatus a -> b #

foldr' :: (a -> b -> b) -> b -> ReadStatus a -> b #

foldl :: (b -> a -> b) -> b -> ReadStatus a -> b #

foldl' :: (b -> a -> b) -> b -> ReadStatus a -> b #

foldr1 :: (a -> a -> a) -> ReadStatus a -> a #

foldl1 :: (a -> a -> a) -> ReadStatus a -> a #

toList :: ReadStatus a -> [a] #

null :: ReadStatus a -> Bool #

length :: ReadStatus a -> Int #

elem :: Eq a => a -> ReadStatus a -> Bool #

maximum :: Ord a => ReadStatus a -> a #

minimum :: Ord a => ReadStatus a -> a #

sum :: Num a => ReadStatus a -> a #

product :: Num a => ReadStatus a -> a #

Traversable ReadStatus Source # 
Instance details

Defined in EventSource.Types

Methods

traverse :: Applicative f => (a -> f b) -> ReadStatus a -> f (ReadStatus b) #

sequenceA :: Applicative f => ReadStatus (f a) -> f (ReadStatus a) #

mapM :: Monad m => (a -> m b) -> ReadStatus a -> m (ReadStatus b) #

sequence :: Monad m => ReadStatus (m a) -> m (ReadStatus a) #

Show a => Show (ReadStatus a) Source # 
Instance details

Defined in EventSource.Types

data ReadFailure Source #

Represents the different kind of failure you can get when reading.