distributed-process-0.4.2: Cloud Haskell: Erlang-style concurrency in Haskell

Safe HaskellNone

Control.Distributed.Process.Internal.Types

Contents

Description

Types used throughout the Cloud Haskell framework

We collect all types used internally in a single module because many of these data types are mutually recursive and cannot be split across modules.

Synopsis

Node and process identifiers

newtype NodeId Source

Node identifier

Constructors

NodeId 

data LocalProcessId Source

A local process ID consists of a seed which distinguishes processes from different instances of the same local node and a counter

Constructors

LocalProcessId 

data ProcessId Source

Process identifier

Constructors

ProcessId 

Fields

processNodeId :: !NodeId

The ID of the node the process is running on

processLocalId :: !LocalProcessId

Node-local identifier for the process

Local nodes and processes

data LocalNode Source

Local nodes

Constructors

LocalNode 

Fields

localNodeId :: !NodeId

NodeId of the node

localEndPoint :: !EndPoint

The network endpoint associated with this node

localState :: !(StrictMVar LocalNodeState)

Local node state

localCtrlChan :: !(Chan NCMsg)

Channel for the node controller

localTracer :: !Tracer

Current active system debug/trace log

remoteTable :: !RemoteTable

Runtime lookup table for supporting closures TODO: this should be part of the CH state, not the local endpoint state

Instances

data Tracer Source

Required for system tracing in the node controller

data LocalNodeState Source

Local node state

Constructors

LocalNodeState 

Fields

_localProcesses :: !(Map LocalProcessId LocalProcess)

Processes running on this node

_localPidCounter :: !Int32

Counter to assign PIDs

_localPidUnique :: !Int32

The unique value used to create PIDs (so that processes on restarted nodes have new PIDs)

_localConnections :: !(Map (Identifier, Identifier) (Connection, ImplicitReconnect))

Outgoing connections

runLocalProcess :: LocalProcess -> Process a -> IO aSource

Deconstructor for Process (not exported to the public API)

Typed channels

data SendPortId Source

A send port is identified by a SendPortId.

You cannot send directly to a SendPortId; instead, use newChan to create a SendPort.

Constructors

SendPortId 

Fields

sendPortProcessId :: !ProcessId

The ID of the process that will receive messages sent on this port

sendPortLocalId :: !LocalSendPortId

Process-local ID of the channel

data TypedChannel Source

Constructors

forall a . Serializable a => TypedChannel (Weak (TQueue a)) 

newtype SendPort a Source

The send send of a typed channel (serializable)

Constructors

SendPort 

Fields

sendPortId :: SendPortId

The (unique) ID of this send port

newtype ReceivePort a Source

The receive end of a typed channel (not serializable)

Note that ReceivePort implements Functor, Applicative, Alternative and Monad. This is especially useful when merging receive ports.

Constructors

ReceivePort 

Fields

receiveSTM :: STM a
 

Messages

data Message Source

Messages consist of their typeRep fingerprint and their encoding

Instances

createMessage :: Serializable a => a -> MessageSource

Turn any serialiable term into a message

messageToPayload :: Message -> [ByteString]Source

Serialize a message

payloadToMessage :: [ByteString] -> MessageSource

Deserialize a message

Node controller user-visible data types

data MonitorRef Source

MonitorRef is opaque for regular Cloud Haskell processes

Constructors

MonitorRef 

Fields

monitorRefIdent :: !Identifier

ID of the entity to be monitored

monitorRefCounter :: !Int32

Unique to distinguish multiple monitor requests by the same process

data PortLinkException Source

Exception thrown when a linked channel (port) dies

data ProcessRegistrationException Source

Exception thrown when a process attempts to register a process under an already-registered name or to unregister a name that hasn't been registered

data DiedReason Source

Why did a process die?

Constructors

DiedNormal

Normal termination

DiedException !String

The process exited with an exception (provided as String because Exception does not implement Binary)

DiedDisconnect

We got disconnected from the process node

DiedNodeDown

The process node died

DiedUnknownId

Invalid (processnodechannel) identifier

newtype DidUnmonitor Source

(Asynchronous) reply from unmonitor

Constructors

DidUnmonitor MonitorRef 

newtype DidUnlinkProcess Source

(Asynchronous) reply from unlink

newtype DidUnlinkNode Source

(Asynchronous) reply from unlinkNode

Constructors

DidUnlinkNode NodeId 

newtype DidUnlinkPort Source

(Asynchronous) reply from unlinkPort

newtype SpawnRef Source

SpawnRef are used to return pids of spawned processes

Constructors

SpawnRef Int32 

data DidSpawn Source

(Asynchronius) reply from spawn

data WhereIsReply Source

(Asynchronous) reply from whereis

data RegisterReply Source

(Asynchronous) reply from register and unregister

Constructors

RegisterReply String Bool 

Node controller internal data types

data NCMsg Source

Messages to the node controller

Instances

Accessors

Utilities

forever' :: Monad m => m a -> m bSource