extensible-effects-concurrent-0.26.1: Message passing concurrency as extensible-effect

Safe HaskellNone
LanguageHaskell2010

Control.Eff.Concurrent.Protocol.Client

Contents

Description

Functions for protocol clients.

This modules is required to write clients that sendPdus.

Synopsis

Calling APIs directly

cast :: forall o' o r q. (HasCallStack, SetMember Process (Process q) r, Member Interrupts r, IsPdu o' Asynchronous, IsPdu 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

castSingleton :: forall outer inner q e. (HasCallStack, EmbedProtocol outer inner, Member (EndpointReader outer) e, SetMember Process (Process q) e, Member Interrupts e, IsPdu outer Asynchronous, IsPdu inner Asynchronous) => Pdu inner Asynchronous -> Eff e () Source #

Like castEndpointReader, but uses embedPdu to embed the value.

This function makes use of AmbigousTypes and TypeApplications.

When not working with an embedded Pdu use castEndpointReader.

Since: 0.25.1

castEndpointReader :: forall o r q. (ServesProtocol o r q, HasCallStack, Member Interrupts r, IsPdu o Asynchronous) => Pdu o Asynchronous -> Eff r () Source #

Like cast but take the Endpoint from the reader provided by runEndpointReader.

When working with an embedded Pdu use castSingleton.

callSingleton :: forall outer inner reply q e. (HasCallStack, EmbedProtocol outer inner, Member (EndpointReader outer) e, SetMember Process (Process q) e, Member Interrupts e, TangiblePdu outer (Synchronous reply), TangiblePdu inner (Synchronous reply), Tangible reply) => Pdu inner (Synchronous reply) -> Eff e reply Source #

Like callEndpointReader, uses embedPdu to embed the value.

This function makes use of AmbigousTypes and TypeApplications.

When not working with an embedded Pdu use callEndpointReader.

Since: 0.25.1

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.

When working with an embedded Pdu use callSingleton.

type ServesProtocol o r q = (Typeable o, SetMember Process (Process q) r, Member (EndpointReader o) r) Source #

Instead of passing around a Endpoint value and passing to functions like cast or call, a Endpoint can provided by a Reader effect, if there is only a single server for a given Pdu instance. This type alias is convenience to express that an effect has Process and a reader for a Endpoint.

type EndpointReader o = Reader (Endpoint o) Source #

The reader effect for ProcessIds for Pdus, 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.