Copyright | (c) Hideyuki Tanaka, 2010-2015 |
---|---|
License | BSD3 |
Maintainer | [email protected] |
Stability | experimental |
Portability | portable |
Safe Haskell | None |
Language | Haskell2010 |
Network.MessagePack.Server
Description
This module is server library of MessagePack-RPC. The specification of MessagePack-RPC is at http://redmine.msgpack.org/projects/msgpack/wiki/RPCProtocolSpec.
A simple example:
import Network.MessagePackRpc.Server add :: Int -> Int -> Server Int add x y = return $ x + y main = serve 1234 [ method "add" add ]
- data Method m
- class Monad m => MethodType m f where
- newtype ServerT m a = ServerT {
- runServerT :: m a
- type Server = ServerT IO
- method :: MethodType m f => String -> f -> Method m
- serve :: (MonadBaseControl IO m, MonadIO m, MonadCatch m, MonadThrow m) => Int -> [Method m] -> m ()
RPC method types
class Monad m => MethodType m f where Source
Instances
(MonadThrow m, MessagePack o, MethodType m r) => MethodType m (o -> r) Source | |
(MonadThrow m, MessagePack o) => MethodType m (ServerT m o) Source |
Constructors
ServerT | |
Fields
|
Instances
MonadTrans ServerT Source | |
(MonadThrow m, MessagePack o) => MethodType m (ServerT m o) Source | |
Monad m => Monad (ServerT m) Source | |
Functor m => Functor (ServerT m) Source | |
Applicative m => Applicative (ServerT m) Source | |
MonadIO m => MonadIO (ServerT m) Source |
Build a method
Arguments
:: MethodType m f | |
=> String | Method name |
-> f | Method body |
-> Method m |
Build a method
Start RPC server
Arguments
:: (MonadBaseControl IO m, MonadIO m, MonadCatch m, MonadThrow m) | |
=> Int | Port number |
-> [Method m] | list of methods |
-> m () |
Start RPC server with a set of RPC methods.