test
Safe HaskellSafe-Inferred
LanguageHaskell2010

Test.Mux.ReqResp

Description

A simple ReqResp protocol, togetether with an incremental decoder. Mux is chopping messages into MuxSDUs of a fixed size, for that reasone the peer awaiting for messages needs an incremental decoder to assemple messages back.

Synopsis

Documentation

data MsgReqResp req resp Source #

Protocol messages.

Constructors

MsgReq req

Client request.

MsgResp resp

Server response.

MsgDone

Client finishes the protocol exchange.

Instances

Instances details
(Show req, Show resp) ⇒ Show (MsgReqResp req resp) Source # 
Instance details

Defined in Test.Mux.ReqResp

Methods

showsPrecIntMsgReqResp req resp → ShowS #

showMsgReqResp req resp → String #

showList ∷ [MsgReqResp req resp] → ShowS #

(Eq req, Eq resp) ⇒ Eq (MsgReqResp req resp) Source # 
Instance details

Defined in Test.Mux.ReqResp

Methods

(==)MsgReqResp req resp → MsgReqResp req resp → Bool #

(/=)MsgReqResp req resp → MsgReqResp req resp → Bool #

(Ord req, Ord resp) ⇒ Ord (MsgReqResp req resp) Source # 
Instance details

Defined in Test.Mux.ReqResp

Methods

compareMsgReqResp req resp → MsgReqResp req resp → Ordering #

(<)MsgReqResp req resp → MsgReqResp req resp → Bool #

(<=)MsgReqResp req resp → MsgReqResp req resp → Bool #

(>)MsgReqResp req resp → MsgReqResp req resp → Bool #

(>=)MsgReqResp req resp → MsgReqResp req resp → Bool #

maxMsgReqResp req resp → MsgReqResp req resp → MsgReqResp req resp #

minMsgReqResp req resp → MsgReqResp req resp → MsgReqResp req resp #

(Serialise req, Serialise resp) ⇒ Serialise (MsgReqResp req resp) Source # 
Instance details

Defined in Test.Mux.ReqResp

Methods

encodeMsgReqResp req resp → Encoding Source #

decodeDecoder s (MsgReqResp req resp) Source #

encodeList ∷ [MsgReqResp req resp] → Encoding Source #

decodeListDecoder s [MsgReqResp req resp] Source #

data ReqRespClient req resp m a where Source #

A Client which requests req data and receives resp.

Constructors

SendMsgReq ∷ req → (resp → m (ReqRespClient req resp m a)) → ReqRespClient req resp m a 
SendMsgDone ∷ m a → ReqRespClient req resp m a 
EarlyExit ∷ a → ReqRespClient req resp m a 

data TraceSendRecv msg Source #

Instances

Instances details
Show msg ⇒ Show (TraceSendRecv msg) Source # 
Instance details

Defined in Test.Mux.ReqResp

Methods

showsPrecIntTraceSendRecv msg → ShowS #

showTraceSendRecv msg → String #

showList ∷ [TraceSendRecv msg] → ShowS #

runClient ∷ ∀ req resp m a. (MonadST m, Serialise req, Serialise resp, Show req, Show resp) ⇒ Tracer m (TraceSendRecv (MsgReqResp req resp)) → Channel m → ReqRespClient req resp m a → m (a, Maybe ByteString) Source #

Run a client using a byte Channel.

data ReqRespServer req resp m a Source #

Server which receives req and responds with resp.

Constructors

ReqRespServer 

Fields

  • recvMsgReq ∷ req → m (resp, ReqRespServer req resp m a)

    The client sent us a ping message. We have no choices here, and the response is nullary, all we have are local effects.

  • recvMsgDone ∷ m a

    The client terminated. Here we have a pure return value, but we could have done another action in m if we wanted to.

runServer ∷ ∀ req resp m a. (MonadST m, Serialise req, Serialise resp, Show req, Show resp) ⇒ Tracer m (TraceSendRecv (MsgReqResp req resp)) → Channel m → ReqRespServer req resp m a → m (a, Maybe ByteString) Source #