Copyright | (C) 2015, The University of Kansas |
---|---|
License | BSD-style (see the file LICENSE) |
Maintainer | Justin Dawson |
Stability | Alpha |
Portability | GHC |
Safe Haskell | None |
Language | Haskell2010 |
- router :: MonadCatch m => (forall a. [m a] -> m [a]) -> (Call :~> m) -> ReceiveAPI :~> m
- data ReceiveAPI :: * -> * where
- Receive :: Value -> ReceiveAPI (Maybe Value)
- data Call :: * -> * where
- CallMethod :: Text -> Args -> Call Value
- CallNotification :: Text -> Args -> Call ()
- transport :: Monad f => (ReceiveAPI :~> f) -> SendAPI :~> f
- methodNotFound :: MonadThrow m => m a
- invalidParams :: MonadThrow m => m a
- parseError :: Value
The server RPC router
router :: MonadCatch m => (forall a. [m a] -> m [a]) -> (Call :~> m) -> ReceiveAPI :~> m Source
"The Server MAY process a batch rpc call as a set of concurrent tasks, processing them in any order and with any width of parallelism." We control this using the first argument.
The datatype that represents what we receive and what we dispatch
data ReceiveAPI :: * -> * where Source
The server-side recieived API. The user provides a way of dispatching this, to implement a server. An example of this using scotty is found in remote-json-server
Receive :: Value -> ReceiveAPI (Maybe Value) |
Show (ReceiveAPI a) Source |
data Call :: * -> * where Source
Call
is a user-visable deep embedding of a method or notification call.
Server's provide transformations on this to implement remote-side call dispatching.
CallMethod :: Text -> Args -> Call Value | |
CallNotification :: Text -> Args -> Call () |
Utilty methods
transport :: Monad f => (ReceiveAPI :~> f) -> SendAPI :~> f Source
transport
connects the ability to recieve a message with the ability
to send a message. Typically this is done using TCP/IP and HTTP,
but we can simulate the connection here.
methodNotFound :: MonadThrow m => m a Source
Throw this exception when a 'JSONCall a -> IO a' fails to match a method or notification.
invalidParams :: MonadThrow m => m a Source
Throw this for when a 'JSONCall a -> IO a' method matches, but has invalid params.
For use when parsing to a JSON value fails inside a server, before calling the router