Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- data HandleError
- newtype Handler output = Handler {
- fromHandler :: ReaderT Message (Except HandleError) output
- runHandler :: Handler output -> Message -> Either HandleError output
- getMessage :: Handler Message
- getParsedMessage :: (FromJSON payload, FromJSON metadata) => Handler (ParsedMessage payload metadata)
- type Handlers output = Map MessageType (Handler output)
- emptyHandlers :: Handlers output
- listToHandlers :: [(MessageType, Handler output)] -> Handlers output
- addHandler :: MessageType -> Handler output -> Handlers output -> Handlers output
- removeHandler :: MessageType -> Handlers output -> Handlers output
- handle :: Handlers output -> Message -> Either HandleError output
- type ProjectionHandler state = Handler (Endo state)
- projectionHandler :: forall payload metadata state. (FromJSON payload, FromJSON metadata) => (Message -> payload -> metadata -> state -> state) -> ProjectionHandler state
- type ProjectionHandlers state = Handlers (Endo state)
- addProjectionHandler :: forall payload metadata state. (FromJSON payload, FromJSON metadata) => MessageType -> (Message -> payload -> metadata -> state -> state) -> ProjectionHandlers state -> ProjectionHandlers state
- projectionHandle :: ProjectionHandlers state -> Message -> state -> Either HandleError state
- type SubscriptionHandler = Handler (IO ())
- subscriptionHandler :: forall payload metadata. (FromJSON payload, FromJSON metadata) => (Message -> payload -> metadata -> IO ()) -> SubscriptionHandler
- type SubscriptionHandlers = Handlers (IO ())
- addSubscriptionHandler :: forall payload metadata. (FromJSON payload, FromJSON metadata) => MessageType -> (Message -> payload -> metadata -> IO ()) -> SubscriptionHandlers -> SubscriptionHandlers
- subscriptionHandle :: SubscriptionHandlers -> Message -> IO (Either HandleError ())
Documentation
data HandleError Source #
An error that may occur from handling a message.
Instances
newtype Handler output Source #
Handler | |
|
Instances
Monad Handler Source # | |
Functor Handler Source # | |
Applicative Handler Source # | |
MonadReader Message Handler Source # | |
MonadError HandleError Handler Source # | |
Defined in MessageDb.Handlers throwError :: HandleError -> Handler a # catchError :: Handler a -> (HandleError -> Handler a) -> Handler a # | |
Semigroup output => Semigroup (Handler output) Source # | |
Monoid output => Monoid (Handler output) Source # | |
runHandler :: Handler output -> Message -> Either HandleError output Source #
getParsedMessage :: (FromJSON payload, FromJSON metadata) => Handler (ParsedMessage payload metadata) Source #
emptyHandlers :: Handlers output Source #
listToHandlers :: [(MessageType, Handler output)] -> Handlers output Source #
addHandler :: MessageType -> Handler output -> Handlers output -> Handlers output Source #
removeHandler :: MessageType -> Handlers output -> Handlers output Source #
type ProjectionHandler state = Handler (Endo state) Source #
projectionHandler :: forall payload metadata state. (FromJSON payload, FromJSON metadata) => (Message -> payload -> metadata -> state -> state) -> ProjectionHandler state Source #
type ProjectionHandlers state = Handlers (Endo state) Source #
addProjectionHandler :: forall payload metadata state. (FromJSON payload, FromJSON metadata) => MessageType -> (Message -> payload -> metadata -> state -> state) -> ProjectionHandlers state -> ProjectionHandlers state Source #
projectionHandle :: ProjectionHandlers state -> Message -> state -> Either HandleError state Source #
type SubscriptionHandler = Handler (IO ()) Source #
subscriptionHandler :: forall payload metadata. (FromJSON payload, FromJSON metadata) => (Message -> payload -> metadata -> IO ()) -> SubscriptionHandler Source #
type SubscriptionHandlers = Handlers (IO ()) Source #
addSubscriptionHandler :: forall payload metadata. (FromJSON payload, FromJSON metadata) => MessageType -> (Message -> payload -> metadata -> IO ()) -> SubscriptionHandlers -> SubscriptionHandlers Source #
subscriptionHandle :: SubscriptionHandlers -> Message -> IO (Either HandleError ()) Source #