network-messagepack-rpc-0.1.2.0: MessagePack RPC

Safe HaskellSafe
LanguageHaskell2010

Network.MessagePack.RPC.Client

Contents

Description

Backend-free MessagePack RPC Client.

Synopsis

Config

data Config Source #

Configuration for MessagePack RPC.

Constructors

Config 

Fields

type NotificationHandler = Client -> MethodName -> [Object] -> IO () Source #

Notification handler. The 3rd argument is response objects.

type RequestHandler = Client -> MessageId -> MethodName -> [Object] -> IO () Source #

Notification handler. The 2nd argument is message id to be used for replying. The 3rd argument is response objects.

type Logger = String -> IO () Source #

Logger type. Should print out the message passed as a first argument somewhere.

type Formatter = Message -> String Source #

Convert Message into a String to print out by Logger

defaultConfig :: Config Source #

The default configuration. formatter is show. Others do nothing.

Backend

data Backend Source #

Backend IO functions. Any receiving / sending actions are performed by calling these functions.

Constructors

Backend 

Fields

Client

data Client Source #

A client data type for MessagePack RPC.

withClient :: Config -> Backend -> (Client -> IO a) -> IO a Source #

Executing the action in the 3rd argument with a Client.

shutdown :: Client -> IO () Source #

This function cleans up the internal states including the termination of internal threads.

Call and reply

type Result = Either Object Object Source #

Result type of a RPC call. Described as "error" and "result" of "Response Message" in the spec of MessagePack RPC.

call :: Client -> MethodName -> [Object] -> IO Result Source #

Calling RPC.

reply :: Client -> MessageId -> Result -> IO () Source #

Replying RPC. This should be used in RequestHandler.