Safe Haskell | None |
---|---|
Language | Haskell2010 |
Functions for protocol clients.
This modules is required to write clients that sendPdu
s.
Synopsis
- cast :: forall o' o r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r, TangiblePdu o' Asynchronous, TangiblePdu o Asynchronous, EmbedProtocol o' o) => Endpoint o' -> Pdu o Asynchronous -> Eff r ()
- call :: forall result protocol' protocol r q. (SetMember Process (Process q) r, Member Interrupts r, TangiblePdu protocol' (Synchronous result), TangiblePdu protocol (Synchronous result), EmbedProtocol protocol' protocol, Tangible result, HasCallStack) => Endpoint protocol' -> Pdu protocol (Synchronous result) -> Eff r result
- callWithTimeout :: forall result protocol' protocol r q. (SetMember Process (Process q) r, Member Interrupts r, TangiblePdu protocol' (Synchronous result), TangiblePdu protocol (Synchronous result), EmbedProtocol protocol' protocol, Tangible result, Member Logs r, Lifted IO q, Lifted IO r, HasCallStack) => Endpoint protocol' -> Pdu protocol (Synchronous result) -> Timeout -> Eff r result
- castEndpointReader :: forall o r q. (ServesProtocol o r q, HasCallStack, Member Interrupts r, TangiblePdu o Asynchronous) => Pdu o Asynchronous -> Eff r ()
- callEndpointReader :: forall reply o r q. (ServesProtocol o r q, HasCallStack, Tangible reply, TangiblePdu o (Synchronous reply), Member Interrupts r) => Pdu o (Synchronous reply) -> Eff r reply
- type ServesProtocol o r q = (Typeable o, SetMember Process (Process q) r, Member (EndpointReader o) r)
- type EndpointReader o = Reader (Endpoint o)
- askEndpoint :: Member (EndpointReader o) e => Eff e (Endpoint o)
- runEndpointReader :: HasCallStack => Endpoint o -> Eff (EndpointReader o ': r) a -> Eff r a
Calling APIs directly
cast :: forall o' o r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r, TangiblePdu o' Asynchronous, TangiblePdu o Asynchronous, EmbedProtocol o' o) => Endpoint o' -> Pdu o Asynchronous -> Eff r () Source #
Send a request Pdu
that has no reply and return immediately.
The type signature enforces that the corresponding Pdu
clause is
Asynchronous
. The operation never fails, if it is important to know if the
message was delivered, use call
instead.
The message will be reduced to normal form (rnf
) in the caller process.
call :: forall result protocol' protocol r q. (SetMember Process (Process q) r, Member Interrupts r, TangiblePdu protocol' (Synchronous result), TangiblePdu protocol (Synchronous result), EmbedProtocol protocol' protocol, Tangible result, HasCallStack) => Endpoint protocol' -> Pdu protocol (Synchronous result) -> Eff r result Source #
Send a request Pdu
and wait for the server to return a result value.
The type signature enforces that the corresponding Pdu
clause is
Synchronous
.
Always prefer callWithTimeout
over call
callWithTimeout :: forall result protocol' protocol r q. (SetMember Process (Process q) r, Member Interrupts r, TangiblePdu protocol' (Synchronous result), TangiblePdu protocol (Synchronous result), EmbedProtocol protocol' protocol, Tangible result, Member Logs r, Lifted IO q, Lifted IO r, HasCallStack) => Endpoint protocol' -> Pdu protocol (Synchronous result) -> Timeout -> Eff r result Source #
Send an request Pdu
and wait for the server to return a result value.
The type signature enforces that the corresponding Pdu
clause is
Synchronous
.
If the server that was called dies, this function interrupts the
process with ProcessDown
.
If the server takes longer to reply than the given timeout, this
function interrupts the process with TimeoutInterrupt
.
Always prefer this function over call
Since: 0.22.0
Server Process Registration
castEndpointReader :: forall o r q. (ServesProtocol o r q, HasCallStack, Member Interrupts r, TangiblePdu o Asynchronous) => Pdu o Asynchronous -> Eff r () Source #
Like cast
but take the Endpoint
from the reader provided by
runEndpointReader
.
callEndpointReader :: forall reply o r q. (ServesProtocol o r q, HasCallStack, Tangible reply, TangiblePdu o (Synchronous reply), Member Interrupts r) => Pdu o (Synchronous reply) -> Eff r reply Source #
Like call
but take the Endpoint
from the reader provided by
runEndpointReader
.
type ServesProtocol o r q = (Typeable o, SetMember Process (Process q) r, Member (EndpointReader o) r) Source #
type EndpointReader o = Reader (Endpoint o) Source #
The reader effect for ProcessId
s for Pdu
s, see runEndpointReader
askEndpoint :: Member (EndpointReader o) e => Eff e (Endpoint o) Source #
Get the Endpoint
registered with runEndpointReader
.
runEndpointReader :: HasCallStack => Endpoint o -> Eff (EndpointReader o ': r) a -> Eff r a Source #
Run a reader effect that contains the one server handling a specific
Pdu
instance.