Echo.Process

Echo.Process

Sub-sections

Contents

Sub sections

ActorSys
Client
Cluster
Config
Messages
Session
Strategy

class AppProfile Source #

Application profile

It provides the core settings used when initialising the Process system. You don't create it yourself, it is passed to you once the config system has successfully parsed the config files.

Fields

field ProcessName NodeName Source #

The name of the running process system node Comes from the 'node-name' attribute in the configuration file.

field ProcessName Role Source #

The role of the running process system Comes from the 'role' attribute in the configuration file.

field string ClusterConn Source #

The cluster connection string Comes from the 'connection' attribute in the configuration file.

field string ClusterDb Source #

The cluster db name (in Redis this is "0"-"15"). Comes from the 'database' attribute in the configuration file.

field Option<SystemName> Env Source #

The environment name (this comes from the cluster variable name in the config file). Use this to build staging environments or to run multiple systems.

i.e  cluster dev:
        node-name:     ms-1
        role:          mail-system
        string sql-db: "dev.example.com"
        ..

     cluster production:
        node-name: ms-1
        role:      mail-system
        string sql-db: "live.example.com"

field Option<string> UserEnv Source #

A user environment

class DeadLetter Source #

Dead letter message

Fields

field ProcessId Sender Source #

Sender of the letter that ended up 'dead'

field ProcessId Recipient Source #

Intended recipient of the message that ended up 'dead'

field Option<Exception> Exception Source #

Any exception that was thrown the cause the letter to die

field Option<string> Reason Source #

An optional reason why the letter died

field Option<object> Message Source #

The content of the dead letter

Properties

property string ContentDisplay Source #

Summary of the message content

property string ContentTypeDisplay Source #

Friendly type display

Methods

method DeadLetter create (ProcessId sender, ProcessId recipient, Exception ex, string reason, object message) Source #

Create a new dead letter

method DeadLetter create (ProcessId sender, ProcessId recipient, string reason, object message) Source #

Create a new dead letter

method DeadLetter create (ProcessId sender, ProcessId recipient, Exception ex, object message) Source #

Create a new dead letter

method DeadLetter create (ProcessId sender, ProcessId recipient, object message) Source #

Create a new dead letter

method string ToString () Source #

Get a string representation of the dead letter

class Dispatch Source #

Methods

method ProcessId register (ProcessName name, Func<ProcessId, IEnumerable<ProcessId>> selector) Source #

Registers a dispatcher for a role Dispatchers take in a 'leaf' ProcessId (i.e. /user/my-process) and return an enumerable of real ProcessIds that the Process system will use to deliver all of the standard functions like tell, ask, subscribe, etc.

Parameters

param name

Name of the dispatcher

param selector

Function that will be invoked every time a dispatcher based ProcessId is used.

returns

A root dispatcher ProcessId. Use this to create new ProcessIds that will be passed to the selector function whenever the dispatcher based ProcessId is used

method Unit deregister (ProcessName name) Source #

Removes the dispatcher registration for the named dispatcher

Parameters

param name

Name of the dispatcher to remove

method ProcessId broadcast (IEnumerable<ProcessId> processIds) Source #

Builds a ProcessId that represents a set of Processes. When used for operations like 'tell', the message is dispatched to all Processes in the set.

Examples

tell( Dispatch.broadcast(pid1,pid2,pid3), "Hello" );

method ProcessId leastBusy (IEnumerable<ProcessId> processIds) Source #

Builds a ProcessId that represents a set of Processes. When used for operations like 'tell', the message is dispatched to the least busy Process from the set.

Examples

tell( Dispatch.leastBusy(pid1,pid2,pid3), "Hello" );

method ProcessId random (IEnumerable<ProcessId> processIds) Source #

Builds a ProcessId that represents a set of Processes. When used for operations like 'tell', the message is dispatched to a cryptographically random Process from the set.

Examples

tell( Dispatch.random(pid1,pid2,pid3), "Hello" );

method ProcessId roundRobin (IEnumerable<ProcessId> processIds) Source #

Builds a ProcessId that represents a set of Processes. When used for operations like 'tell', the message is dispatched to the Processes in a round-robin fashion

Examples

tell( Dispatch.roundRobin(pid1,pid2,pid3), "Hello" );

method ProcessId broadcast (ProcessId processId, params ProcessId[] processIds) Source #

Builds a ProcessId that represents a set of Processes. When used for operations like 'tell', the message is dispatched to all Processes in the set.

Examples

tell( Dispatch.broadcast(pid1,pid2,pid3), "Hello" );

method ProcessId leastBusy (ProcessId processId, params ProcessId[] processIds) Source #

Builds a ProcessId that represents a set of Processes. When used for operations like 'tell', the message is dispatched to the least busy Process from the set.

Examples

tell( Dispatch.leastBusy(pid1,pid2,pid3), "Hello" );

method ProcessId random (ProcessId processId, params ProcessId[] processIds) Source #

Builds a ProcessId that represents a set of Processes. When used for operations like 'tell', the message is dispatched to a cryptographically random Process from the set.

Examples

tell( Dispatch.random(pid1,pid2,pid3), "Hello" );

method ProcessId roundRobin (ProcessId processId, params ProcessId[] processIds) Source #

Builds a ProcessId that represents a set of Processes. When used for operations like 'tell', the message is dispatched to the Processes in a round-robin fashion

Examples

tell( Dispatch.roundRobin(pid1,pid2,pid3), "Hello" );

method Func<ProcessId, IEnumerable<ProcessId>> getFunc (ProcessName name) Source #

method Option<Func<ProcessId, IEnumerable<ProcessId>>> getFuncOption (ProcessName name) Source #

interface HasEcho <RT> Source #

where RT : struct, HasCancel<RT>, HasEncoding<RT>, HasTime<RT>, HasFile<RT>

Placeholder Echo trait

Parameters

type RT

Runtime

class NamedProcessAlreadyExistsException Source #

Named process already exists

Constructors

constructor NamedProcessAlreadyExistsException (string message) Source #

Ctor

constructor NamedProcessAlreadyExistsException (string message, Exception innerException) Source #

Ctor

class InvalidSystemNameException Source #

Invalid SystemName

Constructors

constructor InvalidSystemNameException () Source #

Ctor

constructor InvalidSystemNameException (string message) Source #

Ctor

constructor InvalidSystemNameException (string message, Exception innerException) Source #

Ctor

class InvalidProcessNameException Source #

Invalid process name

Constructors

constructor InvalidProcessNameException () Source #

Ctor

constructor InvalidProcessNameException (string message) Source #

Ctor

constructor InvalidProcessNameException (string message, Exception innerException) Source #

Ctor

class InvalidProcessIdException Source #

Invalid process ID

Constructors

constructor InvalidProcessIdException () Source #

Ctor

constructor InvalidProcessIdException (string message) Source #

Ctor

constructor InvalidProcessIdException (string message, Exception innerException) Source #

Ctor

class NoChildProcessesException Source #

NoChildProcessesException

Constructors

constructor NoChildProcessesException () Source #

Ctor

constructor NoChildProcessesException (string message) Source #

Ctor

constructor NoChildProcessesException (string message, Exception innerException) Source #

Ctor

class AskException Source #

The message can't be asked

Constructors

constructor AskException (string message) Source #

class ProcessException Source #

A process threw an exception in its message loop

Fields

field string Self Source #

Process that threw the exception

field string Sender Source #

Process that sent the message

Constructors

constructor ProcessException (string message, string self, string sender, Exception innerException) Source #

Ctor

constructor ProcessException (string message, string self, string sender) Source #

Ctor

class ProcessSetupException Source #

A process threw an exception in its setup function

Fields

field string Self Source #

Process that threw the exception

Constructors

constructor ProcessSetupException (string self, Exception innerException) Source #

Ctor

class ProcessKillException Source #

Kill process

Constructors

constructor ProcessKillException () Source #

Ctor

constructor ProcessKillException (string message) Source #

Ctor

constructor ProcessKillException (string message, Exception innerException) Source #

Ctor

class ProcessInboxFullException Source #

Process inbox is full

Constructors

constructor ProcessInboxFullException (ProcessId pid, int maximumSize, string type) Source #

Ctor

class ProcessSessionExpired Source #

Session expired

Constructors

constructor ProcessSessionExpired () Source #

Ctor

class NoRouterWorkersException Source #

There are no children to route the message to

Constructors

constructor NoRouterWorkersException () Source #

Ctor

class ProcessConfigException Source #

Constructors

constructor ProcessConfigException (string message) Source #

constructor ProcessConfigException (string message, Exception innerException) Source #

class QueueFullException Source #

Constructors

constructor QueueFullException () Source #

constructor QueueFullException (string message) Source #

constructor QueueFullException (string message, Exception innerException) Source #

class ClientDisconnectedException Source #

Fields

field ClientConnectionId Id Source #

Constructors

constructor ClientDisconnectedException (ClientConnectionId id) Source #

constructor ClientDisconnectedException (ClientConnectionId id, string message) Source #

constructor ClientDisconnectedException (ClientConnectionId id, string message, Exception innerException) Source #

class ProcessSystemException Source #

Properties

property string StackTrace Source #

property string Message Source #

Methods

method string ToString () Source #

interface IProcess <in T> Source #

Represents a process as an object rather than a function

Parameters

type T

Message type

class JsonBinder Source #

Attempts to deal with the issue of serialising between .NET Framework and .NET Core The core libraries of each framework have different names, and the serialised types have these names embedded. This binder attempts to use the assembly and type-name provided. If it fails then it calls Type.GetType which has the following documented behaviour:

"If the type is in the currently executing assembly or in mscorlib.dll/System.Private.CoreLib.dll, it is sufficient to supply the type name qualified by its namespace"

https://docs.microsoft.com/en-us/dotnet/api/system.type.gettype?view=net-5.0

It also looks for the TypeForwardedFrom attribute which is used to indicate a type moved from one assembly to another in the past. So this acts like a redirect. We can send both assembly-names with the messages so we can try both when deserialising.

Methods

method Type BindToType (string asm, string tyname) Source #

Takes an assembly-name and type-name and tries to get the concrete Type

This can handle multiple assembly names and will try them all. If it fails then it will do a last gasp attempt at loading via the Type.GetType function (which doesn't need an assembly name in all circumstances)

method void BindToName (Type serializedType, out string assemblyName, out string typeName) Source #

Takes a known type and extracts an-assembly name and type-name from it

This checks for a TypeForwardedFrom attribute, which is what library writers use to indicate that the type used to exist in another assembly with a different name. If this is the case then we return both assembly names with a '|' separator. This means that the deserialiser can try both assembly names.

class Process Source #

Process: Ask functions

'ask' is a request/response system for processes.  You can ask a process a question (a message) and it
can reply using the 'Process.reply' function.  It doesn't have to and 'ask' will timeout after
ActorConfig.Default.Timeout seconds.

'ask' is blocking, because mostly it will be called from within a process and processes shouldn't
perform asynchronous operations.

Methods

method T ask <T> (ProcessId pid, object message, ProcessId sender) Source #

Ask a process for a reply

Parameters

param pid

Process to ask

param message

Message to send

param sender

Sender process

returns

The response to the request

method T ask <T> (ProcessId pid, object message) Source #

Ask a process for a reply

Parameters

param pid

Process to ask

param message

Message to send

returns

The response to the request

method Task<R> askAsync <R> (ProcessId pid, object message, ProcessId sender) Source #

Asynchronous ask - must be used outside of a Process

Parameters

type R

Type of the return value

param pid

Process to ask

param message

Message to send

param sender

Sender process

returns

A promise to return a response to the request

method Option<T> askIfAlive <T> (ProcessId pid, object message, ProcessId sender) Source #

Ask a process for a reply (if the process is running). If the process isn't running then None is returned

Parameters

param pid

Process to ask

param message

Message to send

param sender

Sender process

returns

The response to the request or None if the process isn't running

method Option<T> askIfAlive <T> (ProcessId pid, object message) Source #

Ask a process for a reply (if the process is running). If the process isn't running then None is returned

Parameters

param pid

Process to ask

param message

Message to send

returns

The response to the request or None if the process isn't running

method Task<R> askAsync <R> (ProcessId pid, object message) Source #

Asynchronous ask - must be used outside of a Process

Parameters

type R

Type of the return value

param pid

Process to ask

param message

Message to send

returns

A promise to return a response to the request

method IEnumerable<T> askChildren <T> (object message, int take = Int32.MaxValue) Source #

Ask children the same message

Parameters

param message

Message to send

returns

method T askParent <T> (object message) Source #

Ask parent process for a reply

Parameters

param message

Message to send

returns

The response to the request

method T askChild <T> (ProcessName name, object message) Source #

Ask a named child process for a reply

Parameters

param message

Message to send

param name

Name of the child process

method T askChild <T> (int index, object message) Source #

Ask a child process (found by index) for a reply

Because of the potential changeable nature of child nodes, this will take the index and mod it by the number of children. We expect this call will mostly be used for load balancing, and round-robin type behaviour, so feel that's acceptable.

Parameters

param message

Message to send

param index

Index of the child process (see remarks)

class ProcessConfig Source #

Methods

method Unit initialiseWeb (IEnumerable<FuncSpec> strategyFuncs = null) Source #

Process system configuration initialisation This will look for cluster.conf and process.conf files in the web application folder, you should call this function from within Application_BeginRequest of Global.asax. It can run multiple times, once the config has loaded the system won't re-load the config until you call ProcessConfig.unload() by ProcessConfig.initialiseWeb(...)

Parameters

param strategyFuncs

Plugin extra strategy behaviours by passing in a list of FuncSpecs.

method Unit initialiseWeb (Action setup, IEnumerable<FuncSpec> strategyFuncs = null) Source #

Process system configuration initialisation This will look for cluster.conf and process.conf files in the web application folder, you should call this function from within Application_BeginRequest of Global.asax. It can run multiple times, once the config has loaded the system won't re-load the config until you call ProcessConfig.unload() followed by ProcessConfig.initialiseWeb(...)

NOTE: If a cluster is specified in the cluster.conf and its 'node-name' matches the host name of the web- application (i.e. www.example.com), then those settings will be used to connect to the cluster. This allows for different staging environments to be setup.

Parameters

param setup

A setup function to call on successful loading of the configuration files - this will happen once only.

param strategyFuncs

Plugin extra strategy behaviours by passing in a list of FuncSpecs.

method Unit initialiseWeb (string nodeName, IEnumerable<FuncSpec> strategyFuncs = null) Source #

Process system configuration initialisation This will look for cluster.conf and process.conf files in the web application folder, you should call this function from within Application_BeginRequest of Global.asax or in the Configuration function of an OWIN Startup type.

Parameters

param nodeName

Web-site host-name: i.e. www.example.com - you would usually call this when you have your first Request object: HttpContext.Request.Url.Host. Could also be the site- name: System.Web.Hosting.HostingEnvironment.SiteName. Anything that will identify this node, and allow for multiple staging environments to be configured in the cluster.conf

i.e.

object sync = new object();
bool started = false;

        static bool started = false;
        static object sync = new object();

        protected void Application_BeginRequest(Object sender, EventArgs e)
        {
            if (!started)
            {
                lock (sync)
                {
                    if (!started)
                    {
                        ProcessConfig.initialiseWeb(HttpContext.Request.Url.Host);
                        started = true;
                    }
                }
            }
        }

param strategyFuncs

Plugin extra strategy behaviours by passing in a list of FuncSpecs.

method Unit initialiseWeb (string nodeName, Action setup, IEnumerable<FuncSpec> strategyFuncs = null, string appPath = null) Source #

Parameters

param nodeName

Web-site host-name: i.e. www.example.com - you would usually call this when you have your first Request object: HttpContext.Request.Url.Host. Could also be the site- name: System.Web.Hosting.HostingEnvironment.SiteName. Anything that will identify this node, and allow for multiple staging environments to be configured in the cluster.conf

i.e.

object sync = new object();
bool started = false;

        static bool started = false;
        static object sync = new object();

        protected void Application_BeginRequest(Object sender, EventArgs e)
        {
            if (!started)
            {
                lock (sync)
                {
                    if (!started)
                    {
                        ProcessConfig.initialiseWeb(HttpContext.Request.Url.Host);
                        started = true;
                    }
                }
            }
        }

param setup

A setup function to call on successful loading of the configuration files - this will happen once only.

object sync = new object();
bool started = false;

        static bool started = false;
        static object sync = new object();

        protected void Application_BeginRequest(Object sender, EventArgs e)
        {
            if (!started)
            {
                lock (sync)
                {
                    if (!started)
                    {
                        ProcessConfig.initialiseWeb(HttpContext.Request.Url.Host);
                        started = true;
                    }
                }
            }
        }

param strategyFuncs

Plugin extra strategy behaviours by passing in a list of FuncSpecs.

method Unit initialiseFileSystem (string nodeName, IEnumerable<FuncSpec> strategyFuncs = null) Source #

Process system configuration initialisation This will look for cluster.conf and process.conf files in the application folder. It can run multiple times, once the config has loaded the system won't re-load the config until you call ProcessConfig.unload() followed by ProcessConfig.initialiseFileSystem(...), so it's safe to not surround it with ifs.

NOTE: If a cluster is specified in the cluster.conf and its 'node-name' matches nodeName, then those settings will be used to connect to the cluster. This allows for different staging environments to be setup.

Parameters

param nodeName

If a cluster is specified in the cluster.conf and its 'node-name' matches nodeName, then those settings will be used to connect to the cluster. This allows for different staging environments to be setup.

param strategyFuncs

Plugin extra strategy behaviours by passing in a list of FuncSpecs.

method Unit initialiseFileSystem (Action setup, IEnumerable<FuncSpec> strategyFuncs = null) Source #

Process system configuration initialisation This will look for process.conf files in the application folder. It can run multiple times, once the config has loaded the system won't re-load the config until you call ProcessConfig.unload() followed by ProcessConfig.initialiseFileSystem(...), so it's safe to not surround it with ifs.

Parameters

param setup

A setup function to call on successful loading of the configuration files - this will happen once only.

param strategyFuncs

Plugin extra strategy behaviours by passing in a list of FuncSpecs.

method Unit initialiseFileSystem (IEnumerable<FuncSpec> strategyFuncs = null) Source #

Process system configuration initialisation This will look for process.conf files in the application folder. It can run multiple times, once the config has loaded the system won't re-load the config until you call ProcessConfig.unload() followed by ProcessConfig.initialiseFileSystem(...), so it's safe to not surround it with ifs.

Parameters

param strategyFuncs

Plugin extra strategy behaviours by passing in a list of FuncSpecs.

method Unit initialiseFileSystem (string nodeName, Action setup, IEnumerable<FuncSpec> strategyFuncs = null, string appPath = null) Source #

Process system configuration initialisation This will look for cluster.conf and process.conf files in the application folder. It can run multiple times, but once the config has loaded the system won't re-load the config until you call ProcessConfig.unload() followed by ProcessConfig.initialiseFileSystem(...), so it's safe to not surround it with ifs.

NOTE: If a cluster is specified in the cluster.conf and its 'node-name' matches nodeName, then those settings will be used to connect to the cluster. This allows for different staging environments to be setup.

Parameters

param nodeName

If a cluster is specified in the cluster.conf and its 'node-name' matches nodeName, then those settings will be used to connect to the cluster. This allows for different staging environments to be setup.

param setup

A setup function to call on successful loading of the configuration files - this will happen once only.

param strategyFuncs

Plugin extra strategy behaviours by passing in a list of FuncSpecs.

method Unit initialise () Source #

Process system initialisation Initialises am in-memory only Process system

method Unit initialise ( SystemName systemName, ProcessName roleName, ProcessName nodeName, string connectionString, string catalogueName, string providerName = "redis" ) Source #

Initialise without a config file or text

Parameters

param systemName

Name of the system - this is most useful

param roleName
param nodeName
param providerName
param connectionString
param catalogueName
returns

method Unit initialise (string configText, Option<string> nodeName, Action setup = null, IEnumerable<FuncSpec> strategyFuncs = null) Source #

Process system configuration initialisation This will parse the configuration text, It can run multiple times, once the config has loaded the system won't re-load the config until you call ProcessConfig.unload() followed by ProcessConfig.initialise(...), so it's safe to not surround it with ifs.

NOTE: If a cluster is specified in config text and its 'node-name' matches nodeName, then those settings will be used to connect to the cluster. This allows for different staging environments to be setup.

Parameters

param nodeName

If a cluster is specified in the cluster.conf and its 'node-name' matches nodeName, then those settings will be used to connect to the cluster. This allows for different staging environments to be setup.

param setup

A setup function to call on successful loading of the configuration files - this will happen once only.

param strategyFuncs

Plugin extra strategy behaviours by passing in a list of FuncSpecs.

method T read <T> (string name, string prop, T defaultValue, SystemName system = default(SystemName)) Source #

Access a setting If in a Process message loop, then this accesses the configuration settings for the Process from the the configuration file, or stored in the cluster. If not in a Process message loop, then this accesses 'global' configuration settings.

Parameters

param name

Name of the setting

param prop

If the setting is a complex value (like a map or record), then this selects the property of the setting to access

returns

Optional configuration setting value

method T read <T> (string name, T defaultValue) Source #

Access a setting If in a Process message loop, then this accesses the configuration settings for the Process from the the configuration file, or stored in the cluster. If not in a Process message loop, then this accesses 'global' configuration settings.

Parameters

param name

Name of the setting

param prop

If the setting is a complex value (like a map or record), then this selects the property of the setting to access

returns

Optional configuration setting value

method Lst<T> readList <T> (string name, string prop = "value") Source #

Access a list setting If in a Process message loop, then this accesses the configuration settings for the Process from the the configuration file, or stored in the cluster. If not in a Process message loop, then this accesses 'global' configuration settings.

Parameters

param name

Name of the setting

param prop

If the setting is a complex value (like a map or record), then this selects the property of the setting to access

returns

Optional configuration setting value

method HashMap<string, T> readMap <T> (string name, string prop = "value") Source #

Access a map setting If in a Process message loop, then this accesses the configuration settings for the Process from the the configuration file, or stored in the cluster. If not in a Process message loop, then this accesses 'global' configuration settings.

Parameters

param name

Name of the setting

param prop

If the setting is a complex value (like a map or record), then this selects the property of the setting to access

returns

Optional configuration setting value

method Unit write (string name, object value) Source #

Write a setting

Parameters

param name

Name of the setting

param value

Value to set

method Unit write (string name, string prop, object value, SystemName system = default(SystemName)) Source #

Write a setting

Parameters

param name

Name of the setting

param prop

If the setting is a complex value (like a map or record), then this selects the property of the setting to access

param value

Value to set

method Unit clear (string name, string prop, SystemName system = default(SystemName)) Source #

Clear a setting

Parameters

param name

Name of the setting

param prop

If the setting is a complex value (like a map or record), then this selects the property of the setting to access

method Unit clear (SystemName system = default(SystemName)) Source #

Clear all settings for the process (or role if outside of the message-loop of a Process)

class Process Source #

Methods

method Unit dead (object message, string reason, SystemName system = default(SystemName)) Source #

Forward a message to dead-letters (and wrap it in a contextual dead-letter structre)

Parameters

param message

Dead letter message

param reason

Reason for the dead-letter

method Unit dead (object message, Exception ex, SystemName system = default(SystemName)) Source #

Forward a message to dead-letters (and wrap it in a contextual dead-letter structre)

Parameters

param message

Dead letter message

param ex

Exception that caused the dead-letter

method Unit dead (object message, Exception ex, string reason, SystemName system = default(SystemName)) Source #

Forward a message to dead-letters (and wrap it in a contextual dead-letter structre)

Parameters

param message

Dead letter message

param ex

Exception that caused the dead-letter

param reason

Reason for the dead-letter

method Unit dead (string reason, SystemName system = default(SystemName)) Source #

Forward the current message to dead-letters (and wrap it in a contextual dead-letter structre)

Parameters

param reason

Reason for the dead-letter

method Unit dead (Exception ex, SystemName system = default(SystemName)) Source #

Forward the current message to dead-letters (and wrap it in a contextual dead-letter structre)

Parameters

param ex

Exception that caused the dead-letter

method Unit dead (Exception ex, string reason, SystemName system = default(SystemName)) Source #

Forward a message to dead-letters (and wrap it in a contextual dead-letter structre)

Parameters

param ex

Exception that caused the dead-letter

param reason

Reason for the dead-letter

class Process Source #

Process:  Forward functions

'fwd' is used to forward a message onto another process whilst maintaining the original
sender context (for 'ask' responses to go back to the right place).

Methods

method Unit fwd <T> (ProcessId pid, T message) Source #

Forward a message

Parameters

param pid

Process ID to send to

param message

Message to send

method Unit fwd (ProcessId pid) Source #

Forward a message

Parameters

param pid

Process ID to send to

method Unit fwdChild <T> (ProcessName name, T message) Source #

Forward a message to a named child process

Parameters

param message

Message to send

param name

Name of the child process

method Unit fwdChild <T> (int index, T message) Source #

Forward a message to a child process (found by index)

Because of the potential changeable nature of child nodes, this will take the index and mod it by the number of children. We expect this call will mostly be used for load balancing, and round-robin type behaviour, so feel that's acceptable.

Parameters

param message

Message to send

param index

Index of the child process (see remarks)

method Unit fwdChild (ProcessName name) Source #

Forward a message to a named child process

Parameters

param name

Name of the child process

method Unit fwdChild (int index) Source #

Forward a message to a child process (found by index)

Because of the potential changeable nature of child nodes, this will take the index and mod it by the number of children. We expect this call will mostly be used for load balancing, and round-robin type behaviour, so feel that's acceptable.

Parameters

param index

Index of the child process (see remarks)

class Process Source #

Methods

method Option<ICluster> SystemCluster (SystemName system = default(SystemName)) Source #

Not advised to use this directly, but allows access to the underlying data-store.

method ProcessId resolvePID (ProcessId pid) Source #

class Process Source #

Methods

method void logWarn (string message) Source #

Log warning - Internal

method void logUserErr (string message) Source #

Log user error - Internal

method void logErr (Exception ex) Source #

Log user or system error - Internal

method void logErr (string message, Exception ex) Source #

Log user or system error - Internal

method void logErr (string message) Source #

Log user or system error - Internal

class Process Source #

Methods

method ProcessId spawnRoundRobin <T> ( ProcessName Name, int Count, Action<T> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with N worker processes, each message is sent to one worker process in a round robin fashion.

Parameters

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

returns

Process ID of the delegator process

method ProcessId spawnRoundRobin <S, T> ( ProcessName Name, int Count, Func<S> Setup, Func<S, T, S> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with N worker processes, each message is sent to one worker process in a round robin fashion.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

returns

Process ID of the delegator process

class Process Source #

Methods

method Unit publish <T> (T message) Source #

Publish a message for any listening subscribers

This should be used from within a process' message loop only

Parameters

param message

Message to publish

method IDisposable publish <T> (T message, TimeSpan delayFor) Source #

Publish a message for any listening subscribers, delayed.

This should be used from within a process' message loop only

Parameters

param message

Message to publish

param delayFor

How long to delay sending for

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method IDisposable publish <T> (T message, DateTime delayUntil) Source #

Publish a message for any listening subscribers, delayed.

This should be used from within a process' message loop only This will fail to be accurate across a Daylight Saving Time boundary

Parameters

param message

Message to publish

param delayUntil

When to send

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit subscribe (ProcessId pid) Source #

Subscribes our inbox to another process publish stream. When it calls 'publish' it will arrive in our inbox.

This should be used from within a process' message loop only

Parameters

param pid

Process to subscribe to

returns

IDisposable, call IDispose to end the subscription

method Unit unsubscribe (ProcessId pid) Source #

Unsubscribe from a process's publications

Parameters

param pid

Process to unsub from

method IDisposable subscribe <T> (ProcessId pid, IObserver<T> observer) Source #

Subscribe to the process publish stream. When a process calls 'publish' it emits messages that can be consumed using this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

Parameters

returns

IDisposable, call IDispose to end the subscription

method IDisposable subscribe <T> (ProcessId pid, Action<T> onNext, Action<Exception> onError, Action onComplete) Source #

Subscribe to the process publish stream. When a process calls 'publish' it emits messages that can be consumed using this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

Parameters

returns

IDisposable, call IDispose to end the subscription

method IDisposable subscribe <T> (ProcessId pid, Action<T> onNext, Action<Exception> onError) Source #

Subscribe to the process publish stream. When a process calls 'publish' it emits messages that can be consumed using this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

method IDisposable subscribe <T> (ProcessId pid, Action<T> onNext) Source #

Subscribe to the process publish stream. When a process calls 'publish' it emits messages that can be consumed using this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

method IDisposable subscribe <T> (ProcessId pid, Action<T> onNext, Action onComplete) Source #

Subscribe to the process publish stream. When a process calls 'publish' it emits messages that can be consumed using this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

Parameters

returns

IDisposable, call IDispose to end the subscription

method IObservable<T> observe <T> (ProcessId pid) Source #

Get an IObservable for a process publish stream. When a process calls 'publish' it emits messages on the observable returned by this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

Parameters

returns

IObservable T

method IObservable<T> observeUnsafe <T> (ProcessId pid) Source #

Get an IObservable for a process publish stream. When a process calls 'publish' it emits messages on the observable returned by this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, that's why this function is labelled Unsafe. Careful disposing and capture of free variables is required to not break the principles of actors.

Parameters

returns

IObservable T

method IObservable<T> observeState <T> (ProcessId pid) Source #

Get an IObservable for a process's state stream. When a process state updates at the end of its message loop it announces it on the stream returned from this method. You should use this for notification only. Never modify the state object belonging to a process. Best practice is to make the state type immutable.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

Parameters

returns

IObservable T

method IObservable<T> observeStateUnsafe <T> (ProcessId pid) Source #

Get an IObservable for a process's state stream. When a process state updates at the end of its message loop it announces it on the stream returned from this method. You should use this for notification only. Never modify the state object belonging to a process. Best practice is to make the state type immutable.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, that's why this function is labelled Unsafe. Careful disposing and capture of free variables is required to not break the principles of actors.

Parameters

returns

IObservable T

method Unit subscribeState <T> (ProcessId pid) Source #

Subscribes our inbox to another process state publish stream. When a process state updates at the end of its message loop it announces it arrives in our inbox. You should use this for notification only. Never modify the state object belonging to a process. Best practice is to make the state type immutable.

The process can publish any number of types, any published messages not of type T will be ignored. This should be used from within a process' message loop only

Parameters

returns

class Process Source #

Methods

method IEnumerable<ProcessName> queryRegistered (ProcessName role, string keyQuery, SystemName system = default(SystemName)) Source #

Finds all persistent registered names in a role

Parameters

param role

Role to limit search to

param keyQuery

Key query. * is a wildcard

returns

Registered names

method IEnumerable<ProcessId> queryProcesses (string keyQuery, SystemName system = default(SystemName)) Source #

Finds all persistent processes based on the search pattern provided. Note the returned ProcessIds may contain processes that aren't currently active. You can still post to them however.

Parameters

param keyQuery

Key query. * is a wildcard

returns

Matching ProcessIds

method HashMap<ProcessId, ProcessMetaData> queryProcessMetaData (string keyQuery, SystemName system = default(SystemName)) Source #

Finds all persistent processes based on the search pattern provided and then returns the meta-data associated with them.

Parameters

param keyQuery

Key query. * is a wildcard

returns

Map of ProcessId to ProcessMetaData

class Process Source #

Process registration - a kind of DNS for Processes

If the Process is visible to the cluster (PersistInbox) then the
registration becomes a permanent named look-up until Process.deregister
is called.

Multiple Processes can register under the same name.  You may use
a dispatcher to work on them collectively (wherever they are in the
cluster).  i.e.

    var regd = register("regd-name", pid);

    tell(Dispatch.Broadcast[regd],  "Hello");
    tell(Dispatch.First[regd],      "Hello");
    tell(Dispatch.LeastBusy[regd],  "Hello");
    tell(Dispatch.Random[regd],     "Hello");
    tell(Dispatch.RoundRobin[regd], "Hello");

Methods

method ProcessId find (ProcessName name) Source #

Find a process by its registered name (a kind of DNS for Processes).

Names are registered in roles. This function will find registered processes in the current role only. Use the 'find' variant to find registered processes in other roles.

See remarks.

Multiple Processes can register under the same name. You may use a dispatcher to work on them collectively (wherever they are in the cluster). i.e.

var regd = register("proc", pid);
tell(Dispatch.Broadcast[regd], "Hello");
tell(Dispatch.First[regd], "Hello");
tell(Dispatch.LeastBusy[regd], "Hello");
tell(Dispatch.Random[regd], "Hello");
tell(Dispatch.RoundRobin[regd], "Hello");

Parameters

param name

Process name

returns

A ProcessId that allows dispatching to the process(es). The result would look like /disp/reg/name

method ProcessId find (ProcessName role, ProcessName name) Source #

Find a process by its registered name (a kind of DNS for Processes) in the role specified.

See remarks.

Multiple Processes can register under the same name. You may use a dispatcher to work on them collectively (wherever they are in the cluster). i.e.

var regd = register("proc", pid);
tell(Dispatch.Broadcast[regd], "Hello");
tell(Dispatch.First[regd], "Hello");
tell(Dispatch.LeastBusy[regd], "Hello");
tell(Dispatch.Random[regd], "Hello");
tell(Dispatch.RoundRobin[regd], "Hello");

Parameters

param role

Process role

param name

Process name

returns

A ProcessId that allows dispatching to the process(es). The result would look like /disp/reg/name

method ProcessId register (ProcessName name, SystemName system = default(SystemName)) Source #

Register a named process (a kind of DNS for Processes).

If the Process is visible to the cluster (PersistInbox) then the registration becomes a permanent named look-up until Process.deregister is called.

See remarks.

Multiple Processes can register under the same name. You may use a dispatcher to work on them collectively (wherever they are in the cluster). i.e.

var regd = register("proc");
tell(Dispatch.Broadcast[regd], "Hello");
tell(Dispatch.First[regd], "Hello");
tell(Dispatch.LeastBusy[regd], "Hello");
tell(Dispatch.Random[regd], "Hello");
tell(Dispatch.RoundRobin[regd], "Hello");

This should be used from within a process' message loop only

Parameters

param name

Name to register under

returns

A ProcessId that allows dispatching to the process via the name. The result would look like /disp/reg/name

method ProcessId register (ProcessName name, ProcessId process) Source #

Register a named process (a kind of DNS for Processes).

If the Process is visible to the cluster (PersistInbox) then the registration becomes a permanent named look-up until Process.deregister is called.

See remarks.

Multiple Processes can register under the same name. You may use a dispatcher to work on them collectively (wherever they are in the cluster). i.e.

var regd = register("proc", pid);
tell(Dispatch.Broadcast[regd], "Hello");
tell(Dispatch.First[regd], "Hello");
tell(Dispatch.LeastBusy[regd], "Hello");
tell(Dispatch.Random[regd], "Hello");
tell(Dispatch.RoundRobin[regd], "Hello");

Parameters

param name

Name to register under

param process

Process to be registered

returns

A ProcessId that allows dispatching to the process(es). The result would look like /disp/reg/name

method Unit deregisterById (ProcessId process) Source #

Deregister a Process from any names it's been registered as.

See remarks.

Any Process (or dispatcher, or role, etc.) can be registered by a name - a kind of DNS for ProcessIds. There can be multiple names associated with a single ProcessId.

This function removes all registered names for a specific ProcessId. If you wish to deregister all ProcessIds registered under a name then use Process.deregisterByName(name)

Parameters

param process

Process to be deregistered

method Unit deregisterByName (ProcessName name, SystemName system = default(SystemName)) Source #

Deregister all Processes associated with a name. NOTE: Be very careful with usage of this function if you didn't handle the registration you are potentially disconnecting many Processes from their registered name.

See remarks.

Any Process (or dispatcher, or role, etc.) can be registered by a name - a kind of DNS for ProcessIds. There can be multiple names associated with a single ProcessId and multiple ProcessIds associated with a name.

This function removes all registered ProcessIds for a specific name. If you wish to deregister all names registered for specific Process then use Process.deregisterById(pid)

Parameters

param name

Name of the process to deregister

class Process Source #

Process: Reply functions

The reply functions are used to send responses back to processes that have sent
a message using 'ask'.  The replyError variants are for bespoke error handling
but if you let the process throw an exception when something goes wrong, the
Process system will auto-reply with an error response (and throw it for the
process that's asking).  If the asking process doesn't capture the error then
it will continue to cascade to the original asking process.

Fields

field NoReturn noreply = NoReturn.Default Source #

Use this to cancel a reply in the proxy system

Methods

method Unit reply <T> (T message) Source #

Reply to an ask

This should be used from within a process' message loop only

method Unit replyIfAsked <T> (T message) Source #

Reply if asked

This should be used from within a process' message loop only

method Unit replyError (Exception exception) Source #

Reply to an ask with an error

This should be used from within a process' message loop only

method Unit replyError (string errorMessage) Source #

Reply to an ask with an error

This should be used from within a process' message loop only

method Unit replyErrorIfAsked (Exception exception) Source #

Reply with an error if asked

This should be used from within a process' message loop only

method Unit replyErrorIfAsked (string errorMessage) Source #

Reply with an error if asked

This should be used from within a process' message loop only

method Unit replyOrTellSender <T> (T message) Source #

Reply to the asker, or if it's not an ask then tell the sender via a message to their inbox.

class Process Source #

Process: Session functions

These functions facilitate the use of sessions that live from
Process to Process.  Essentially if there's an active Session
ID then it will be packaged with each message that is sent via
tell or ask.

Fields

field IObservable<SessionId> SessionEnded = sessionEnded Source #

field IObservable<SessionId> SessionStarted = sessionStarted Source #

Methods

method SessionId sessionStart (SessionId sid, Time timeout, SystemName system) Source #

Starts a new session in the Process system with the specified session ID

Parameters

param sid

Session ID

param timeout

Session timeout

method SessionId sessionStart (SessionId sid, Time timeout) Source #

Starts a new session in the Process system. This variant must be called from within a Process, use the variant where you specify the SystemName to use it from outside

Parameters

param timeout

Session timeout

returns

sid

method SessionId sessionStart (Time timeout) Source #

Starts a new session in the Process system. This variant must be called from within a Process, use the variant where you specify the SystemName to use it from outside

Parameters

param timeout

Session timeout

returns

Session ID of the newly created session

method Unit sessionStop () Source #

Ends a session in the Process system with the specified session ID

Parameters

param sid

Session ID

method Unit sessionTouch () Source #

Touch a session Time-stamps the session so that its time-to-expiry is reset

method Unit sessionTouch (SessionId sid) Source #

Touch a session Time-stamps the session so that its time-to-expiry is reset and also sets the current session ID. This should be used from inside of the Process system to 'acquire' an existing session. This is useful for web-requests for example to set the current session ID and to indicate activity.

Parameters

param sid

Session ID

method Unit setSession (SessionId sid) Source #

Sets the current session to the provided sessionid

Parameters

param sid
returns

method Option<SessionId> sessionId () Source #

Gets the current session ID

Also touches the session so that its time-to-expiry is reset

Parameters

returns

Optional session ID

method Unit sessionSetData (string key, object value) Source #

Set the meta-data to store with the current session, this is typically user credentials when they've logged in. But can be anything. It is a key/value store that is sync'd around the cluster.

Parameters

param key

Key

param value

Data value

method Unit sessionClearData (string key) Source #

Clear the meta-data key stored with the session

Parameters

param sid

Session ID

param key

Key

method Seq<T> sessionGetData <T> (string key) Source #

Get the meta-data stored with the session.

The session system allows concurrent updates from across the cluster or from within the app-domain (from multiple processes). To maintain the integrity of the data in any one session, the system uses a version clock per-key.

That means that if two Processes update the session from the same 'time' start point, then there will be a conflict and the session will contain both values stored against the key.

It is up to you to decide on the best approach to resolving the conflict. Calling Head() / HeadOrNone() on the result will get the value that was written first, calling Last() will get the value that was written last. However, being first or last doesn't necessarily make a value 'right', in an asynchronous system the last value could be the newest or oldest. Both value commits had the same starting state, so if the consistency of the session data is important to you then you should implement a more robust strategy to deal with value conflicts, if integrity doesn't really matter, call HeadOrNone().

The versioning system is closest to Lamport Clocks. Eventually this implementation will be replaced with a Dotted Version Vector system.

Parameters

param key

Key

method bool hasSession () Source #

Returns True if there is a session ID available. NOTE: That doesn't mean the session is still alive.

Parameters

returns

method R withSession <R> (SessionId sid, Func<R> f) Source #

Acquires a session for the duration of invocation of the provided function. NOTE: This does not create a session, or check that a session exists.

Parameters

param sid

Session ID

param f

Function to invoke

returns

Result of the function

method Unit withSession (SessionId sid, Action f) Source #

Acquires a session ID for the duration of invocation of the provided action. NOTE: This does not create a session, or check that a session exists.

Parameters

param sid

Session ID

param f

Action to invoke

method bool hasActiveSession () Source #

Returns true if the current session is active, returns false if not in message loop or session is not active.

Parameters

returns

method Unit addSupplementarySession (SupplementarySessionId sid) Source #

Adds a supplementary session id to existing session. If the current session already has a supplmentary session replace it

Parameters

param sid
returns

method Option<SessionId> getSessionBySupplementaryId (SupplementarySessionId sid) Source #

Gets a echo session id which contains a supplementary session

Parameters

param sid
returns

method Option<SupplementarySessionId> getSupplementarySessionId () Source #

Get supplementary session id for current session

Parameters

returns

method SupplementarySessionId provideSupplementarySessionId () Source #

Get supplementary session id for current session. If not exists, create a new one.

Parameters

returns

class Process Source #

Process: Spawn functions

The spawn functions create a new process.  Processes are either simple message receivers that
don't manage state and therefore only need a messageHandler.  Or they manage state over time.

If they manage state then you should also provide a 'setup' function that generates the initial
state.  This allows the process system to recover if a process crashes.  It can re-call the
setup function to reset the state and continue processing the messages.

Methods

method ProcessId spawn <T> ( ProcessName Name, Action<T> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Action<ProcessId> Terminated = null ) Source #

Create a new process by name. If this is called from within a process' message loop then the new process will be a child of the current process. If it is called from outside of a process, then it will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

A ProcessId that identifies the child

method ProcessId spawnUnit <T> ( ProcessName Name, Func<T, Unit> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<ProcessId, Unit> Terminated = null ) Source #

Create a new process by name (accepts Unit as a return value instead of void). If this is called from within a process' message loop then the new process will be a child of the current process. If it is called from outside of a process, then it will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

A ProcessId that identifies the child

method ProcessId spawn <S, T> ( ProcessName Name, Func<S> Setup, Func<S, T, S> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<S, ProcessId, S> Terminated = null, Func<S, Unit> Shutdown = null, SystemName System = default(SystemName), bool Lazy = false ) Source #

Create a new process by name. If this is called from within a process' message loop then the new process will be a child of the current process. If it is called from outside of a process, then it will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Name

Name of the child-process

param Setup

Startup and restart function

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param Terminated

Message function to call when a Process [that this Process watches] terminates

param Lazy

If set to true actor will not start automatically, you need to startup(processId) manually

returns

A ProcessId that identifies the child

method IEnumerable<ProcessId> spawnMany <T> ( int Count, ProcessName Name, Action<T> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Action<ProcessId> Terminated = null ) Source #

Create N child processes. The name provided will be used as a basis to generate the child names. Each child will be named "name-index" where index starts at zero. If this is called from within a process' message loop then the new processes will be a children of the current process. If it is called from outside of a process, then they will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Count

Number of processes to spawn

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

ProcessId IEnumerable

method IEnumerable<ProcessId> spawnMany <S, T> ( int Count, ProcessName Name, Func<S> Setup, Func<S, T, S> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<S, Unit> Shutdown = null, Func<S, ProcessId, S> Terminated = null ) Source #

Create N child processes. The name provided will be used as a basis to generate the child names. Each child will be named "name-index" where index starts at zero. If this is called from within a process' message loop then the new processes will be a children of the current process. If it is called from outside of a process, then they will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Count

Number of processes to spawn

param Setup

Startup and restart function

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

ProcessId IEnumerable

method IEnumerable<ProcessId> spawnMany <S, T> ( ProcessName Name, HashMap<int, Func<S>> Spec, Func<S, T, S> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<S, Unit> Shutdown = null, Func<S, ProcessId, S> Terminated = null ) Source #

Create N child processes. The name provided will be used as a basis to generate the child names. Each child will be named "name-index" where index starts at zero. If this is called from within a process' message loop then the new processes will be a children of the current process. If it is called from outside of a process, then they will be made a child of the root 'user' process.

Parameters

type S

State type

type T

Type of messages that the child-process can accept

param Spec

Map of IDs and State for generating child workers

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

ProcessId IEnumerable

method ProcessId spawn <TProcess,TMsg> ( ProcessName Name, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

where TProcess : IProcess<TMsg>, new()

Spawn by type

Parameters

type TProcess

Process type

type TMsg

Message type

param Name

Name of process to spawn

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

returns

ProcessId

method TProcess proxy <TProcess> (ProcessId pid) Source #

Proxy based system for processes that are defined by a single type: their state type. The state type holds state in its member variables and its message handlers are its member functions. This function builds a proxy from the interface passed so that you can invoke the message- handlers in a strongly typed way.

Parameters

type TProcess

Interface type that represents the Process

param pid

ProcessId of the Process to proxy

returns

An interface that automatically tells and asks depending on method arguments and return types.

method TProcessInterface spawn <TProcessInterface> ( ProcessName Name, Func<TProcessInterface> Setup, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawn by iterface type. You must provide a Setup function that returns the concrete implementation of TProcessInterface. Communication is via a generated proxy: the returned TProcessInterface.

Parameters

type TProcess

Process type

param Name

Name of process to spawn

param Setup

You must provide a Setup function that returns the concrete implementation of TProcessInterface

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

returns

TProcessInterface - The proxy for communicating with the Process

method ProcessId spawn <TProcess> ( ProcessName Name, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

where TProcess : new()

Spawn by type. Communication is via proxy - call Process.proxy(pid) on the resulting ProcessId to send tells and asks in a strongly typed fashion.

Parameters

type TProcess

Process type

param Name

Name of process to spawn

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

returns

TProcessInterface - The proxy for communicating with the Process

class Process Source #

Fields

field State<StrategyContext, Unit> DefaultStrategy = OneForOne(Always(Directive.Restart)) Source #

Default Process strategy if one isn't provided on spawn

class Process Source #

Process:  Tell functions

'Tell' is used to send a message from one process to another (or from outside a process to a process).
The messages are sent to the process asynchronously and join the process' inbox.  The process will
deal with one message from its inbox at a time.  It cannot start the next message until it's finished
with a previous message.

Methods

method Unit tell <T> (ProcessId pid, T message, ProcessId sender = default(ProcessId)) Source #

Send a message to a process

Parameters

param pid

Process ID to send to

param message

Message to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Unit tell <T> (ProcessId pid, T message, Schedule schedule, ProcessId sender = default(ProcessId)) Source #

Send a message at a specified time in the future

Parameters

param pid

Process ID to send to

param message

Message to send

param schedule

A structure that defines the method of delivery of the scheduled message

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tell <T> (ProcessId pid, T message, TimeSpan delayFor, ProcessId sender = default(ProcessId)) Source #

Send a message at a specified time in the future

Parameters

param pid

Process ID to send to

param message

Message to send

param delayFor

How long to delay sending for

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tell <T> (ProcessId pid, T message, DateTime delayUntil, ProcessId sender = default(ProcessId)) Source #

Send a message at a specified time in the future

It is advised to use the variant that takes a TimeSpan, this will fail to be accurate across a Daylight Saving Time boundary or if you use non-UTC dates

Parameters

param pid

Process ID to send to

param message

Message to send

param delayUntil

Date and time to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellChildren <T> (T message, ProcessId sender = default(ProcessId)) Source #

Tell children the same message

Parameters

param message

Message to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Unit tellChildren <T> (T message, Schedule schedule, ProcessId sender = default(ProcessId)) Source #

Tell children the same message, delayed.

Parameters

param message

Message to send

param schedule

A structure that defines the method of delivery of the scheduled message

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellChildren <T> (T message, TimeSpan delayFor, ProcessId sender = default(ProcessId)) Source #

Tell children the same message, delayed.

Parameters

param message

Message to send

param delayFor

How long to delay sending for

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellChildren <T> (T message, DateTime delayUntil, ProcessId sender = default(ProcessId)) Source #

Tell children the same message, delayed.

This will fail to be accurate across a Daylight Saving Time boundary

Parameters

param message

Message to send

param delayUntil

Date and time to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellChildren <T> (T message, Func<ProcessId, bool> predicate, ProcessId sender = default(ProcessId)) Source #

Tell children the same message The list of children to send to are filtered by the predicate provided

Parameters

param message

Message to send

param predicate

The list of children to send to are filtered by the predicate provided

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Unit tellChildren <T> (T message, Schedule schedule, Func<ProcessId, bool> predicate, ProcessId sender = default(ProcessId)) Source #

Tell children the same message, delayed. The list of children to send to are filtered by the predicate provided

Parameters

param message

Message to send

param schedule

A structure that defines the method of delivery of the scheduled message

param predicate

The list of children to send to are filtered by the predicate provided

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellChildren <T> (T message, TimeSpan delayFor, Func<ProcessId, bool> predicate, ProcessId sender = default(ProcessId)) Source #

Tell children the same message, delayed. The list of children to send to are filtered by the predicate provided

Parameters

param message

Message to send

param delayFor

How long to delay sending for

param predicate

The list of children to send to are filtered by the predicate provided

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellChildren <T> (T message, DateTime delayUntil, Func<ProcessId, bool> predicate, ProcessId sender = default(ProcessId)) Source #

Tell children the same message, delayed. The list of children to send to are filtered by the predicate provided

This will fail to be accurate across a Daylight Saving Time boundary

Parameters

param message

Message to send

param delayUntil

Date and time to send

param predicate

The list of children to send to are filtered by the predicate provided

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellParent <T> (T message, ProcessId sender = default(ProcessId)) Source #

Send a message to the parent process

Parameters

param message

Message to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Unit tellParent <T> (T message, Schedule schedule, ProcessId sender = default(ProcessId)) Source #

Send a message to the parent process at a specified time in the future

Parameters

param message

Message to send

param schedule

A structure that defines the method of delivery of the scheduled message

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellParent <T> (T message, TimeSpan delayFor, ProcessId sender = default(ProcessId)) Source #

Send a message to the parent process at a specified time in the future

Parameters

param message

Message to send

param delayFor

How long to delay sending for

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellParent <T> (T message, DateTime delayUntil, ProcessId sender = default(ProcessId)) Source #

Send a message to the parent process at a specified time in the future

This will fail to be accurate across a Daylight Saving Time boundary

Parameters

param message

Message to send

param delayUntil

Date and time to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellSelf <T> (T message, ProcessId sender = default(ProcessId)) Source #

Send a message to ourself

Parameters

param message

Message to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Unit tellSelf <T> (T message, Schedule schedule, ProcessId sender = default(ProcessId)) Source #

Send a message to ourself at a specified time in the future

Parameters

param message

Message to send

param schedule

A structure that defines the method of delivery of the scheduled message

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellSelf <T> (T message, TimeSpan delayFor, ProcessId sender = default(ProcessId)) Source #

Send a message to ourself at a specified time in the future

Parameters

param message

Message to send

param delayFor

How long to delay sending for

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellSelf <T> (T message, DateTime delayUntil, ProcessId sender = default(ProcessId)) Source #

Send a message to ourself at a specified time in the future

This will fail to be accurate across a Daylight Saving Time boundary

Parameters

param message

Message to send

param delayUntil

Date and time to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit tellChild <T> (ProcessName name, T message, ProcessId sender = default(ProcessId)) Source #

Send a message to a named child process

Parameters

param message

Message to send

param name

Name of the child process

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Unit tellChild <T> (int index, T message, ProcessId sender = default(ProcessId)) Source #

Send a message to a child process (found by index)

Because of the potential changeable nature of child nodes, this will take the index and mod it by the number of children. We expect this call will mostly be used for load balancing, and round-robin type behaviour, so feel that's acceptable.

Parameters

param message

Message to send

param index

Index of the child process (see remarks)

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

class Process Source #

Methods

method Validation<string, Msg> WillMyMessageSerialiseAndIsEqual <Msg> (Msg msg) Source #

Support for unit testing message serialisation

method Validation<string, Msg> WillMyMessageSerialise <Msg> (Msg msg) Source #

Support for unit testing message serialisation

class Process Source #

The Language Ext process system uses the actor model as seen in Erlang
processes.  Actors are famed for their ability to support massive concurrency
through messaging and no shared memory.

https://en.wikipedia.org/wiki/Actor_model

Each process has an 'inbox' and a state.  The state is the property of the
process and no other.  The messages in the inbox are passed to the process
one at a time.  When the process has finished processing a message it returns
its current state.  This state is then passed back in with the next message.

You can think of it as a fold over a stream of messages.

A process must finish dealing with a message before another will be given.
Therefore they are blocking.  But they block themselves only. The messages
will build up whilst they are processing.

Because of this, processes are also in a 'supervision hierarchy'.  Essentially
each process can spawn child-processes and the parent process 'owns' the child.

Processes have a default failure strategy where the process just restarts with
its original state.  The inbox always survives a crash and the failed message
is sent to a 'dead letters' process.  You can monitor this. You can also provide
bespoke strategies for different types of failure behaviours (See Strategy folder)

So post crash the process restarts and continues processing the next message.

By creating child processes it's possible for a parent process to 'offload'
work.  It could create 10 child processes, and simply route the messages it
gets to its children for a very simple load balancer. Processes are very
lightweight and should not be seen as Threads or Tasks.  You can create
10s of 1000s of them and it will 'just work'.

Scheduled tasks become very simple also.  You can send a process to a message
with a delay.  So a background process that needs to run every 30 minutes
can just send itself a message with a delay on it at the end of its message
handler:

    tellSelf(unit, TimeSpan.FromMinutes(30));

Properties

property IObservable<ShutdownCancellationToken> PreShutdown Source #

Triggers when the Process system shuts down Either subscribe to the OnNext or OnCompleted

property IObservable<SystemName> Shutdown Source #

Triggers when the Process system shuts down Either subscribe to the OnNext or OnCompleted

property IObservable<ProcessLogItem> ProcessSystemLog Source #

Log of everything that's going on in the Languge Ext process system

property ProcessId Self Source #

Current process ID

This should be used from within a process message loop only

property ProcessId Parent Source #

Parent process ID

This should be used from within a process message loop only

property ProcessId Sender Source #

Sender process ID Always valid even if there's not a sender (the 'NoSender' process ID will be provided).

property HashMap<string, ProcessId> Children Source #

Get the child processes of the running process

This should be used from within a process message loop only

property Map<string, ProcessId> ChildrenInOrder Source #

Get the child processes of the running process

This should be used from within a process message loop only

property CancellationToken SelfProcessCancellationToken Source #

Gets a CancellationToken that is in state Cancel when actor will shutdown. This can be used in message loop to e.g. avoid long running message loop blocking actor shutdown.

This should be used from within a process' message loop only

property bool isTell Source #

Return True if the message sent is a Tell and not an Ask

This should be used from within a process' message loop only

property Lst<SystemName> Systems Source #

List of system names running on this node

property bool isAsk Source #

Return True if the message sent is an Ask and not a Tell

This should be used from within a process' message loop only

Methods

method ProcessId Root (SystemName system = default(SystemName)) Source #

Root process ID The Root process is the parent of all processes

method ProcessId User (SystemName system = default(SystemName)) Source #

User process ID The User process is the default entry process, your first process spawned will be a child of this process.

method ProcessId DeadLetters (SystemName system = default(SystemName)) Source #

Dead letters process Subscribe to it to monitor the failed messages ()

method ProcessId Errors (SystemName system = default(SystemName)) Source #

Errors process Subscribe to it to monitor the errors thrown

method HashMap<string, ProcessId> children (ProcessId pid) Source #

Get the child processes of the process ID provided

method Map<string, ProcessId> childrenInOrder (ProcessId pid) Source #

Get the child processes of the process ID provided

method ProcessId child (ProcessName name) Source #

Get the child processes by name

method ProcessId child (int index) Source #

Get the child processes by index.

Because of the potential changeable nature of child nodes, this will take the index and mod it by the number of children. We expect this call will mostly be used for load balancing, and round-robin type behaviour, so feel that's acceptable.

method Unit kill () Source #

Immediately kills the Process that is running from within its message loop. It does this by throwing a ProcessKillException which is caught and triggers the shutdown of the Process. Any Process that has a persistent inbox or state will also have its persistent data wiped. If the Process is registered it will have its registration revoked. If you wish for the data to be maintained for future spawns then call Process.shutdown()

This should be used from within a process' message loop only

method Unit shutdown () Source #

Shutdown the currently running process. The shutdown message jumps ahead of any messages already in the process's queue but doesn't exit immediately like kill(). Any Process that has a persistent inbox or state will have its state maintained for future spawns. If you wish for the data to be dropped then call Process.kill()

method Unit kill (ProcessId pid) Source #

Kill a specified running process. Forces the specified Process to shutdown. The kill message jumps ahead of any messages already in the process's queue. Any Process that has a persistent inbox or state will also have its persistent data wiped. If the Process is registered it will also its registration revoked. If you wish for the data to be maintained for future spawns then call Process.shutdown(pid);

method Unit startup (ProcessId pid) Source #

Send StartupProcess message to a process that isn't running (e.g. spawned with Lazy = true)

method Unit shutdown (ProcessId pid) Source #

Shutdown a specified running process. Forces the specified Process to shutdown. The shutdown message jumps ahead of any messages already in the process's queue. Any Process that has a persistent inbox or state will have its state maintained for future spawns. If you wish for the data to be dropped then call Process.kill(pid)

method Unit shutdownSystem (SystemName system) Source #

Shutdown all processes on the specified process-system

method Unit shutdownAll () Source #

Shutdown all processes on all process-systems

method Unit restart (ProcessId pid) Source #

Forces a running process to restart. This will reset its state and drop any subscribers, or any of its subscriptions.

method Unit pause (ProcessId pid) Source #

Pauses a running process. Messages will still be accepted into the Process' inbox (unless the inbox is full); but they won't be processed until the Process is unpaused:

Parameters

param pid

Process to pause

method IDisposable pauseFor (ProcessId pid, Time delay) Source #

Pauses a running process. Messages will still be accepted into the Process' inbox (unless the inbox is full); but they won't be processed until the Process is unpaused: manually, or until the delay expires.

Parameters

param pid

Process to pause

method Unit unpause (ProcessId pid) Source #

Un-pauses a paused process. Messages that have built-up in the inbox whilst the Process was paused will be Processed immediately.

Parameters

param pid

Process to un-pause

method bool exists (ProcessId pid) Source #

Find out if a process exists

Rules:
    * Local processes   - the process must actually be alive and in-memory
    * Remote processes  - the process must have an inbox to receive messages
                          and may be active, but it's not required.
    * Dispatchers/roles - at least one process in the collection must exist(pid)
    * JS processes      - not current supported

Parameters

param pid

Process ID to check

returns

True if exists

method bool ping (ProcessId pid) Source #

Find out if a process exists and is alive

Rules:
    * Local processes   - the process must actually be running
    * Remote processes  - the process must actually be running
    * Dispatchers/roles - at least one process in the collection must be running
    * JS processes      - not current supported

Parameters

param pid

Process ID to check

returns

True if exists

method Unit watch (ProcessId pid) Source #

Watch another Process in case it terminates

Parameters

param pid

Process to watch

method Unit unwatch (ProcessId pid) Source #

Un-watch another Process that this Process has been watching

Parameters

param pid

Process to watch

method Unit watch (ProcessId watcher, ProcessId watching) Source #

Watch for the death of the watching process and tell the watcher process when that happens.

Parameters

param watcher

Watcher

param watching

Watched

method Unit unwatch (ProcessId watcher, ProcessId watching) Source #

Stop watching for the death of the watching process

Parameters

param watcher

Watcher

param watching

Watched

method int inboxCount (ProcessId pid) Source #

Find the number of items in the Process inbox

Parameters

param pid

Process

returns

Number of items in the Process inbox

method HashMap<ProcessName, ClusterNode> ClusterNodes (SystemName system = default(SystemName)) Source #

Get a list of cluster nodes that are online

method HashMap<ProcessName, ClusterNode> ClusterNodes24 (SystemName system = default(SystemName)) Source #

Get a list of cluster nodes that have been alive in the past 24 hours

method IEnumerable<ProcessId> resolve (ProcessId pid) Source #

Resolves a ProcessId into the absolute ProcessIds that it represents This allows live resolution of role-based ProcessIds to their real node ProcessIds.

Mostly useful for debugging, but could be useful for layering additional logic to any message dispatch.

Parameters

param pid
returns

Enumerable of resolved ProcessIds - could be zero length

method IEnumerable<Type> validMessageTypes (ProcessId pid) Source #

Get the types of messages that the provided ProcessId accepts. Returns an empty list if it can't be resolved for whatever reason (process doesn't exist/JS process/etc.).

Parameters

param pid

Process ID to query

returns

List of types

method Unit reschedule (ProcessId pid, string key, DateTime when) Source #

Re-schedule an already scheduled message

method Unit reschedule (ProcessId pid, string key, TimeSpan when) Source #

Re-schedule an already scheduled message

method Unit cancelScheduled (ProcessId pid, string key) Source #

Cancel an already scheduled message

class Process <RT> Source #

where RT : struct, HasEcho<RT>

Process:  Ask functions

'ask' is a request/response system for processes.  You can ask a process a question (a message) and it
can reply using the 'Process.reply' function.  It doesn't have to and 'ask' will timeout after
ActorConfig.Default.Timeout seconds.

'ask' is blocking, because mostly it will be called from within a process and processes shouldn't
perform asynchronous operations.

Methods

method Aff<RT, A> ask <A> (ProcessId pid, object message, ProcessId sender = default(ProcessId)) Source #

Send a message to a process

Parameters

param pid

Process ID to send to

param message

Message to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Aff<RT, A> ask <A> (Eff<RT, ProcessId> pid, object message, ProcessId sender = default(ProcessId)) Source #

Send a message to a process

Parameters

param pid

Process ID to send to

param message

Message to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Aff<RT, Seq<A>> askChildren <A> (object message, int take = Int32.MaxValue) Source #

Ask children the same message

Parameters

param message

Message to send

param take

Maximum number of children to ask

method Aff<RT, A> askParent <A> (object message) Source #

Send a message to the parent process

Parameters

param message

Message to send

method Aff<RT, A> askChild <A> (ProcessName name, A message) Source #

Send a message to a named child process

Parameters

param message

Message to send

param name

Name of the child process

method Aff<RT, A> askChild <A> (int index, object message) Source #

Send a message to a child process (found by index)

Because of the potential changeable nature of child nodes, this will take the index and mod it by the number of children. We expect this call will mostly be used for load balancing, and round-robin type behaviour, so feel that's acceptable.

Parameters

param message

Message to send

param index

Index of the child process (see remarks)

class Process <RT> Source #

where RT : struct, HasEcho<RT>

The Language Ext process system uses the actor model as seen in Erlang
processes.  Actors are famed for their ability to support massive concurrency
through messaging and no shared memory.

https://en.wikipedia.org/wiki/Actor_model

Each process has an 'inbox' and a state.  The state is the property of the
process and no other.  The messages in the inbox are passed to the process
one at a time.  When the process has finished processing a message it returns
its current state.  This state is then passed back in with the next message.

You can think of it as a fold over a stream of messages.

A process must finish dealing with a message before another will be given.
Therefore they are blocking.  But they block themselves only. The messages
will build up whilst they are processing.

Because of this, processes are also in a 'supervision hierarchy'.  Essentially
each process can spawn child-processes and the parent process 'owns' the child.

Processes have a default failure strategy where the process just restarts with
its original state.  The inbox always survives a crash and the failed message
is sent to a 'dead letters' process.  You can monitor this. You can also provide
bespoke strategies for different types of failure behaviours (See Strategy folder)

So post crash the process restarts and continues processing the next message.

By creating child processes it's possible for a parent process to 'offload'
work.  It could create 10 child processes, and simply route the messages it
gets to its children for a very simple load balancer. Processes are very
lightweight and should not be seen as Threads or Tasks.  You can create
10s of 1000s of them and it will 'just work'.

Scheduled tasks become very simple also.  You can send a process to a message
with a delay.  So a background process that needs to run every 30 minutes
can just send itself a message with a delay on it at the end of its message
handler:

    tellSelf(unit, TimeSpan.FromMinutes(30));

Fields

field Eff<RT, SystemName> System Source #

Current system

TODO: This is a placeholder until the current-system becomes part of the HasEcho trait. Its current behaviour is to return the system of the process being run, or if not inside an inbox, the default-system.

field Eff<RT, ProcessId> Self Source #

Current process ID

This should be used from within a process message loop only

field Eff<RT, ProcessId> Parent Source #

Parent process ID

This should be used from within a process message loop only

field Eff<RT, ProcessId> Sender Source #

Sender process ID Always valid even if there's not a sender (the 'NoSender' process ID will be provided).

field Eff<RT, ProcessId> User Source #

User process ID The User process is the default entry process, your first process spawned will be a child of this process.

field Eff<RT, ProcessId> DeadLetters Source #

Dead letters process Subscribe to it to monitor the failed messages ()

field Eff<RT, ProcessId> Root Source #

Root process ID The Root process is the parent of all processes

field Eff<RT, ProcessId> Errors Source #

Errors process Subscribe to it to monitor the errors thrown

field Eff<RT, HashMap<string, ProcessId>> Children Source #

Get the child processes of the running process

This should be used from within a process message loop only

field Eff<RT, Map<string, ProcessId>> ChildrenInOrder Source #

Get the child processes of the running process

This should be used from within a process message loop only

field Eff<RT, Unit> killSelf Source #

Immediately kills the Process that is running from within its message loop. It does this by throwing a ProcessKillException which is caught and triggers the shutdown of the Process. Any Process that has a persistent inbox or state will also have its persistent data wiped. If the Process is registered it will have its registration revoked. If you wish for the data to be maintained for future spawns then call Process.shutdown()

This should be used from within a process' message loop only

field Eff<RT, Unit> shutdownSelf Source #

Shutdown the currently running process. The shutdown message jumps ahead of any messages already in the process's queue but doesn't exit immediately like kill(). Any Process that has a persistent inbox or state will have its state maintained for future spawns. If you wish for the data to be dropped then call Process.kill()

Properties

property Eff<RT, Unit> shutdownAll Source #

Shutdown all processes on all process-systems

property Eff<RT, bool> isTell Source #

Return True if the message sent is a Tell and not an Ask

This should be used from within a process' message loop only

property Eff<RT, Unit> assertTell Source #

Assert that the current request is a tell

Fails with 'Tell expected' if the current request isn't a tell Fails with 'Not in a message loop' if we're not in a Process

property Eff<RT, HashMap<ProcessName, ClusterNode>> ClusterNodes Source #

Get a list of cluster nodes that are online

property Eff<RT, Seq<SystemName>> Systems Source #

List of system names running on this node

property Eff<RT, bool> isAsk Source #

Return True if the message sent is an Ask and not a Tell

This should be used from within a process' message loop only

property Eff<RT, Unit> assertAsk Source #

Assert that the current request is an ask

Fails with 'Ask expected' if the current request isn't a ask Fails with 'Not in a message loop' if we're not in a Process

Methods

method Aff<RT, HashMap<string, ProcessId>> children (ProcessId pid) Source #

Get the child processes of the process ID provided

method Aff<RT, Map<string, ProcessId>> childrenInOrder (ProcessId pid) Source #

Get the child processes of the process ID provided

method Eff<RT, ProcessId> child (ProcessName name) Source #

Get the child processes by name

method Eff<RT, ProcessId> child (int index) Source #

Get the child processes by index.

Because of the potential changeable nature of child nodes, this will take the index and mod it by the number of children. We expect this call will mostly be used for load balancing, and round-robin type behaviour, so feel that's acceptable.

method Eff<RT, Unit> kill (ProcessId pid) Source #

Kill a specified running process. Forces the specified Process to shutdown. The kill message jumps ahead of any messages already in the process's queue. Any Process that has a persistent inbox or state will also have its persistent data wiped. If the Process is registered it will also its registration revoked. If you wish for the data to be maintained for future spawns then call Process.shutdown(pid);

method Eff<RT, Unit> startup (ProcessId pid) Source #

Send StartupProcess message to a process that isn't running (e.g. spawned with Lazy = true)

method Eff<RT, Unit> shutdown (ProcessId pid) Source #

Shutdown a specified running process. Forces the specified Process to shutdown. The shutdown message jumps ahead of any messages already in the process's queue. Any Process that has a persistent inbox or state will have its state maintained for future spawns. If you wish for the data to be dropped then call Process.kill(pid)

method Eff<RT, Unit> shutdownSystem (SystemName system) Source #

Shutdown all processes on the specified process-system

method Eff<RT, Unit> restart (ProcessId pid) Source #

Forces a running process to restart. This will reset its state and drop any subscribers, or any of its subscriptions.

method Eff<RT, Unit> pause (ProcessId pid) Source #

Pauses a running process. Messages will still be accepted into the Process' inbox (unless the inbox is full); but they won't be processed until the Process is un-paused:

Parameters

param pid

Process to pause

method Eff<RT, IDisposable> pauseFor (ProcessId pid, Time delay) Source #

Pauses a running process. Messages will still be accepted into the Process' inbox (unless the inbox is full); but they won't be processed until the Process is unpaused: manually, or until the delay expires.

Parameters

param pid

Process to pause

param delay

How long to pause for

method Eff<RT, Unit> unpause (ProcessId pid) Source #

Un-pauses a paused process. Messages that have built-up in the inbox whilst the Process was paused will be Processed immediately.

Parameters

param pid

Process to un-pause

method Aff<RT, bool> exists (ProcessId pid) Source #

Find out if a process exists

Rules:
    * Local processes   - the process must actually be alive and in-memory
    * Remote processes  - the process must have an inbox to receive messages
                          and may be active, but it's not required.
    * Dispatchers/roles - at least one process in the collection must exist(pid)
    * JS processes      - not current supported

Parameters

param pid

Process ID to check

returns

True if exists

method Aff<RT, bool> ping (ProcessId pid) Source #

Find out if a process exists and is alive

Rules:
    * Local processes   - the process must actually be running
    * Remote processes  - the process must actually be running
    * Dispatchers/roles - at least one process in the collection must be running
    * JS processes      - not current supported

Parameters

param pid

Process ID to check

returns

True if exists

method Eff<RT, Unit> watch (ProcessId pid) Source #

Watch another Process in case it terminates

Parameters

param pid

Process to watch

method Aff<RT, Unit> unwatch (ProcessId pid) Source #

Un-watch another Process that this Process has been watching

Parameters

param pid

Process to watch

method Aff<RT, Unit> watch (ProcessId watcher, ProcessId watching) Source #

Watch for the death of the watching process and tell the watcher process when that happens.

Parameters

param watcher

Watcher

param watching

Watched

method Aff<RT, Unit> unwatch (ProcessId watcher, ProcessId watching) Source #

Stop watching for the death of the watching process

Parameters

param watcher

Watcher

param watching

Watched

method Aff<RT, int> inboxCount (ProcessId pid) Source #

Find the number of items in the Process inbox

Parameters

param pid

Process

returns

Number of items in the Process inbox

method Eff<RT, IEnumerable<ProcessId>> resolve (ProcessId pid) Source #

Resolves a ProcessId into the absolute ProcessIds that it represents This allows live resolution of role-based ProcessIds to their real node ProcessIds.

Mostly useful for debugging, but could be useful for layering additional logic to any message dispatch.

Parameters

param pid
returns

Enumerable of resolved ProcessIds - could be zero length

method Aff<RT, IEnumerable<Type>> validMessageTypes (ProcessId pid) Source #

Get the types of messages that the provided ProcessId accepts. Returns an empty list if it can't be resolved for whatever reason (process doesn't exist/JS process/etc.).

Parameters

param pid

Process ID to query

returns

List of types

method Eff<RT, Unit> reschedule (ProcessId pid, string key, DateTime when) Source #

Re-schedule an already scheduled message

method Eff<RT, Unit> reschedule (ProcessId pid, string key, TimeSpan when) Source #

Re-schedule an already scheduled message

method Eff<RT, Unit> cancelScheduled (ProcessId pid, string key) Source #

Cancel an already scheduled message

class Process <RT> Source #

where RT : struct, HasEcho<RT>

Process registration - a kind of DNS for Processes

If the Process is visible to the cluster (PersistInbox) then the
registration becomes a permanent named look-up until Process.deregister
is called.

Multiple Processes can register under the same name.  You may use
a dispatcher to work on them collectively (wherever they are in the
cluster).  i.e.

    var regd = register("regd-name", pid);

    tell(Dispatch.Broadcast[regd],  "Hello");
    tell(Dispatch.First[regd],      "Hello");
    tell(Dispatch.LeastBusy[regd],  "Hello");
    tell(Dispatch.Random[regd],     "Hello");
    tell(Dispatch.RoundRobin[regd], "Hello");

Methods

method Eff<RT, ProcessId> find (ProcessName name) Source #

Find a process by its registered name (a kind of DNS for Processes).

Names are registered in roles. This function will find registered processes in the current role only. Use the 'find' variant to find registered processes in other roles.

See remarks.

Multiple Processes can register under the same name. You may use a dispatcher to work on them collectively (wherever they are in the cluster). i.e.

var regd = register("proc", pid);
tell(Dispatch.Broadcast[regd], "Hello");
tell(Dispatch.First[regd], "Hello");
tell(Dispatch.LeastBusy[regd], "Hello");
tell(Dispatch.Random[regd], "Hello");
tell(Dispatch.RoundRobin[regd], "Hello");

Parameters

param name

Process name

returns

A ProcessId that allows dispatching to the process(es). The result would look like /disp/reg/name

method Eff<RT, ProcessId> find (ProcessName role, ProcessName name) Source #

Find a process by its registered name (a kind of DNS for Processes) in the role specified.

See remarks.

Multiple Processes can register under the same name. You may use a dispatcher to work on them collectively (wherever they are in the cluster). i.e.

var regd = register("proc", pid);
tell(Dispatch.Broadcast[regd], "Hello");
tell(Dispatch.First[regd], "Hello");
tell(Dispatch.LeastBusy[regd], "Hello");
tell(Dispatch.Random[regd], "Hello");
tell(Dispatch.RoundRobin[regd], "Hello");

Parameters

param role

Process role

param name

Process name

returns

A ProcessId that allows dispatching to the process(es). The result would look like /disp/reg/name

method Aff<RT, ProcessId> register (ProcessName name) Source #

Register a named process (a kind of DNS for Processes).

If the Process is visible to the cluster (PersistInbox) then the registration becomes a permanent named look-up until Process.deregister is called.

See remarks.

Multiple Processes can register under the same name. You may use a dispatcher to work on them collectively (wherever they are in the cluster). i.e.

var regd = register("proc");
tell(Dispatch.Broadcast[regd], "Hello");
tell(Dispatch.First[regd], "Hello");
tell(Dispatch.LeastBusy[regd], "Hello");
tell(Dispatch.Random[regd], "Hello");
tell(Dispatch.RoundRobin[regd], "Hello");

This should be used from within a process' message loop only

Parameters

param name

Name to register under

returns

A ProcessId that allows dispatching to the process via the name. The result would look like /disp/reg/name

method Aff<RT, ProcessId> register (ProcessName name, ProcessId process) Source #

Register a named process (a kind of DNS for Processes).

If the Process is visible to the cluster (PersistInbox) then the registration becomes a permanent named look-up until Process.deregister is called.

See remarks.

Multiple Processes can register under the same name. You may use a dispatcher to work on them collectively (wherever they are in the cluster). i.e.

var regd = register("proc", pid);
tell(Dispatch.Broadcast[regd], "Hello");
tell(Dispatch.First[regd], "Hello");
tell(Dispatch.LeastBusy[regd], "Hello");
tell(Dispatch.Random[regd], "Hello");
tell(Dispatch.RoundRobin[regd], "Hello");

Parameters

param name

Name to register under

param process

Process to be registered

returns

A ProcessId that allows dispatching to the process(es). The result would look like /disp/reg/name

method Aff<RT, Unit> deregisterById (ProcessId process) Source #

Deregister a Process from any names it's been registered as.

See remarks.

Any Process (or dispatcher, or role, etc.) can be registered by a name - a kind of DNS for ProcessIds. There can be multiple names associated with a single ProcessId.

This function removes all registered names for a specific ProcessId. If you wish to deregister all ProcessIds registered under a name then use Process.deregisterByName(name)

Parameters

param process

Process to be deregistered

method Aff<RT, Unit> deregisterByName (ProcessName name) Source #

Deregister all Processes associated with a name. NOTE: Be very careful with usage of this function if you didn't handle the registration you are potentially disconnecting many Processes from their registered name.

See remarks.

Any Process (or dispatcher, or role, etc.) can be registered by a name - a kind of DNS for ProcessIds. There can be multiple names associated with a single ProcessId and multiple ProcessIds associated with a name.

This function removes all registered ProcessIds for a specific name. If you wish to deregister all names registered for specific Process then use Process.deregisterById(pid)

Parameters

param name

Name of the process to deregister

class Process <RT> Source #

where RT : struct, HasEcho<RT>

Process: Reply functions

The reply functions are used to send responses back to processes that have sent
a message using 'ask'.  The replyError variants are for bespoke error handling
but if you let the process throw an exception when something goes wrong, the
Process system will auto-reply with an error response (and throw it for the
process that's asking).  If the asking process doesn't capture the error then
it will continue to cascade to the original asking process.

Fields

field NoReturn noreply = NoReturn.Default Source #

Use this to cancel a reply in the proxy system

Methods

method Eff<RT, Unit> reply <A> (A message) Source #

Reply to an ask

This should be used from within a process' message loop only

method Eff<RT, Unit> replyIfAsked <A> (A message) Source #

Reply if asked

This should be used from within a process' message loop only

method Eff<RT, Unit> replyError (Exception exception) Source #

Reply to an ask with an error

This should be used from within a process' message loop only

method Eff<RT, Unit> replyError (string errorMessage) Source #

Reply to an ask with an error

This should be used from within a process' message loop only

method Eff<RT, Unit> replyErrorIfAsked (Exception exception) Source #

Reply with an error if asked

This should be used from within a process' message loop only

method Eff<RT, Unit> replyErrorIfAsked (string errorMessage) Source #

Reply with an error if asked

This should be used from within a process' message loop only

method Eff<RT, Unit> replyOrTellSender <A> (A message) Source #

Reply to the asker, or if it's not an ask then tell the sender via a message to their inbox.

class Process <RT> Source #

where RT : struct, HasEcho<RT>

Process: Spawn functions

The spawn functions create a new process.  Processes are either simple message receivers that
don't manage state and therefore only need a messageHandler.  Or they manage state over time.

If they manage state then you should also provide a 'setup' function that generates the initial
state.  This allows the process system to recover if a process crashes.  It can re-call the
setup function to reset the state and continue processing the messages.

Methods

method Eff<RT, ProcessId> spawn <T> ( ProcessName Name, Func<T, Aff<RT, Unit>> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<ProcessId, Aff<RT, Unit>> Terminated = null) Source #

Create a new process by name. If this is called from within a process' message loop then the new process will be a child of the current process. If it is called from outside of a process, then it will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

A ProcessId that identifies the child

method Eff<RT, ProcessId> spawnUnit <T> ( ProcessName Name, Func<T, Aff<RT, Unit>> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<ProcessId, Aff<RT, Unit>> Terminated = null) Source #

Create a new process by name (accepts Unit as a return value instead of void). If this is called from within a process' message loop then the new process will be a child of the current process. If it is called from outside of a process, then it will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

A ProcessId that identifies the child

method Eff<RT, ProcessId> spawn <S, T> ( ProcessName Name, Aff<RT, S> Setup, Func<S, T, Aff<RT, S>> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<S, ProcessId, Aff<RT, S>> Terminated = null, Func<S, Aff<RT, Unit>> Shutdown = null, bool Lazy = false) Source #

Create a new process by name. If this is called from within a process' message loop then the new process will be a child of the current process. If it is called from outside of a process, then it will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Name

Name of the child-process

param Setup

Startup and restart function

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum number of messages that can back up in the process

param Terminated

Message function to call when a Process [that this Process watches] terminates

param Shutdown

Process to call on shutdown

param Lazy

If set to true actor will not start automatically, you need to startup(processId) manually

returns

A ProcessId that identifies the child

method Eff<RT, Seq<ProcessId>> spawnMany <T> ( int Count, ProcessName Name, Func<T, Aff<RT, Unit>> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<ProcessId, Aff<RT, Unit>> Terminated = null) Source #

Create N child processes. The name provided will be used as a basis to generate the child names. Each child will be named "name-index" where index starts at zero. If this is called from within a process' message loop then the new processes will be a children of the current process. If it is called from outside of a process, then they will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Count

Number of processes to spawn

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

ProcessId IEnumerable

method Eff<RT, Seq<ProcessId>> spawnMany <S, T> ( int Count, ProcessName Name, Aff<RT, S> Setup, Func<S, T, Aff<RT, S>> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<S, Aff<RT, Unit>> Shutdown = null, Func<S, ProcessId, Aff<RT, S>> Terminated = null) Source #

Create N child processes. The name provided will be used as a basis to generate the child names. Each child will be named "name-index" where index starts at zero. If this is called from within a process' message loop then the new processes will be a children of the current process. If it is called from outside of a process, then they will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Count

Number of processes to spawn

param Setup

Startup and restart function

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

ProcessId IEnumerable

method Eff<RT, Seq<ProcessId>> spawnMany <S, T> ( ProcessName Name, HashMap<int, Aff<RT, S>> Spec, Func<S, T, Aff<RT, S>> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<S, Aff<RT, Unit>> Shutdown = null, Func<S, ProcessId, Aff<RT, S>> Terminated = null) Source #

Create N child processes. The name provided will be used as a basis to generate the child names. Each child will be named "name-index" where index starts at zero. If this is called from within a process' message loop then the new processes will be a children of the current process. If it is called from outside of a process, then they will be made a child of the root 'user' process.

Parameters

type S

State type

type T

Type of messages that the child-process can accept

param Spec

Map of IDs and State for generating child workers

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

ProcessId IEnumerable

class Process <RT> Source #

where RT : struct, HasEcho<RT>

Process: Spawn functions

The spawn functions create a new process.  Processes are either simple message receivers that
don't manage state and therefore only need a messageHandler.  Or they manage state over time.

If they manage state then you should also provide a 'setup' function that generates the initial
state.  This allows the process system to recover if a process crashes.  It can re-call the
setup function to reset the state and continue processing the messages.

Methods

method Eff<RT, ProcessId> spawn <T> ( ProcessName Name, Func<T, Eff<RT, Unit>> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<ProcessId, Eff<RT, Unit>> Terminated = null) Source #

Create a new process by name. If this is called from within a process' message loop then the new process will be a child of the current process. If it is called from outside of a process, then it will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

A ProcessId that identifies the child

method Eff<RT, ProcessId> spawnUnit <T> ( ProcessName Name, Func<T, Eff<RT, Unit>> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<ProcessId, Eff<RT, Unit>> Terminated = null) Source #

Create a new process by name (accepts Unit as a return value instead of void). If this is called from within a process' message loop then the new process will be a child of the current process. If it is called from outside of a process, then it will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

A ProcessId that identifies the child

method Eff<RT, ProcessId> spawn <S, T> ( ProcessName Name, Eff<RT, S> Setup, Func<S, T, Eff<RT, S>> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<S, ProcessId, Eff<RT, S>> Terminated = null, Func<S, Eff<RT, Unit>> Shutdown = null, bool Lazy = false) Source #

Create a new process by name. If this is called from within a process' message loop then the new process will be a child of the current process. If it is called from outside of a process, then it will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Name

Name of the child-process

param Setup

Startup and restart function

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum number of messages that can back up in the process

param Terminated

Message function to call when a Process [that this Process watches] terminates

param Shutdown

Process to call on shutdown

param Lazy

If set to true actor will not start automatically, you need to startup(processId) manually

returns

A ProcessId that identifies the child

method Eff<RT, Seq<ProcessId>> spawnMany <T> ( int Count, ProcessName Name, Func<T, Eff<RT, Unit>> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<ProcessId, Eff<RT, Unit>> Terminated = null) Source #

Create N child processes. The name provided will be used as a basis to generate the child names. Each child will be named "name-index" where index starts at zero. If this is called from within a process' message loop then the new processes will be a children of the current process. If it is called from outside of a process, then they will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Count

Number of processes to spawn

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

ProcessId IEnumerable

method Eff<RT, Seq<ProcessId>> spawnMany <S, T> ( int Count, ProcessName Name, Eff<RT, S> Setup, Func<S, T, Eff<RT, S>> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<S, Eff<RT, Unit>> Shutdown = null, Func<S, ProcessId, Eff<RT, S>> Terminated = null) Source #

Create N child processes. The name provided will be used as a basis to generate the child names. Each child will be named "name-index" where index starts at zero. If this is called from within a process' message loop then the new processes will be a children of the current process. If it is called from outside of a process, then they will be made a child of the root 'user' process.

Parameters

type T

Type of messages that the child-process can accept

param Count

Number of processes to spawn

param Setup

Startup and restart function

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

ProcessId IEnumerable

method Eff<RT, Seq<ProcessId>> spawnMany <S, T> ( ProcessName Name, HashMap<int, Eff<RT, S>> Spec, Func<S, T, Eff<RT, S>> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, Func<S, Eff<RT, Unit>> Shutdown = null, Func<S, ProcessId, Eff<RT, S>> Terminated = null) Source #

Create N child processes. The name provided will be used as a basis to generate the child names. Each child will be named "name-index" where index starts at zero. If this is called from within a process' message loop then the new processes will be a children of the current process. If it is called from outside of a process, then they will be made a child of the root 'user' process.

Parameters

type S

State type

type T

Type of messages that the child-process can accept

param Spec

Map of IDs and State for generating child workers

param Name

Name of the child-process

param Inbox

Function that is the process

param Flags

Process flags

param Strategy

Failure supervision strategy

param MaxMailboxSize

Maximum inbox size

param Terminated

Message function to call when a Process [that this Process watches] terminates

returns

ProcessId IEnumerable

class Process <RT> Source #

where RT : struct, HasEcho<RT>

Process:  Tell functions

'Tell' is used to send a message from one process to another (or from outside a process to a process).
The messages are sent to the process asynchronously and join the process' inbox.  The process will
deal with one message from its inbox at a time.  It cannot start the next message until it's finished
with a previous message.

Methods

method Eff<RT, Unit> tell <A> (ProcessId pid, A message, ProcessId sender = default(ProcessId)) Source #

Send a message to a process

Parameters

param pid

Process ID to send to

param message

Message to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Eff<RT, Unit> tell <A> (Eff<RT, ProcessId> pid, A message, ProcessId sender = default(ProcessId)) Source #

Send a message to a process

Parameters

param pid

Process ID to send to

param message

Message to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Eff<RT, Unit> tell <A> (ProcessId pid, A message, Schedule schedule, ProcessId sender = default(ProcessId)) Source #

Send a message at a specified time in the future

Parameters

param pid

Process ID to send to

param message

Message to send

param schedule

A structure that defines the method of delivery of the scheduled message

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tell <A> (Eff<RT, ProcessId> pid, A message, Schedule schedule, ProcessId sender = default(ProcessId)) Source #

Send a message at a specified time in the future

Parameters

param pid

Process ID to send to

param message

Message to send

param schedule

A structure that defines the method of delivery of the scheduled message

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tell <A> (ProcessId pid, A message, TimeSpan delayFor, ProcessId sender = default(ProcessId)) Source #

Send a message at a specified time in the future

Parameters

param pid

Process ID to send to

param message

Message to send

param delayFor

How long to delay sending for

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tell <A> (Eff<RT, ProcessId> pid, A message, TimeSpan delayFor, ProcessId sender = default(ProcessId)) Source #

Send a message at a specified time in the future

Parameters

param pid

Process ID to send to

param message

Message to send

param delayFor

How long to delay sending for

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tell <A> (ProcessId pid, A message, DateTime delayUntil, ProcessId sender = default(ProcessId)) Source #

Send a message at a specified time in the future

It is advised to use the variant that takes a TimeSpan, this will fail to be accurate across a Daylight Saving Time boundary or if you use non-UTC dates

Parameters

param pid

Process ID to send to

param message

Message to send

param delayUntil

Date and time to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tell <A> (Eff<RT, ProcessId> pid, A message, DateTime delayUntil, ProcessId sender = default(ProcessId)) Source #

Send a message at a specified time in the future

It is advised to use the variant that takes a TimeSpan, this will fail to be accurate across a Daylight Saving Time boundary or if you use non-UTC dates

Parameters

param pid

Process ID to send to

param message

Message to send

param delayUntil

Date and time to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellChildren <A> (A message, ProcessId sender = default(ProcessId)) Source #

Tell children the same message

Parameters

param message

Message to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Eff<RT, Unit> tellChildren <A> (A message, Schedule schedule, ProcessId sender = default(ProcessId)) Source #

Tell children the same message, delayed.

Parameters

param message

Message to send

param schedule

A structure that defines the method of delivery of the scheduled message

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellChildren <A> (A message, TimeSpan delayFor, ProcessId sender = default(ProcessId)) Source #

Tell children the same message, delayed.

Parameters

param message

Message to send

param delayFor

How long to delay sending for

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellChildren <A> (A message, DateTime delayUntil, ProcessId sender = default(ProcessId)) Source #

Tell children the same message, delayed.

This will fail to be accurate across a Daylight Saving Time boundary

Parameters

param message

Message to send

param delayUntil

Date and time to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellChildren <A> (A message, Func<ProcessId, bool> predicate, ProcessId sender = default(ProcessId)) Source #

Tell children the same message The list of children to send to are filtered by the predicate provided

Parameters

param message

Message to send

param predicate

The list of children to send to are filtered by the predicate provided

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Eff<RT, Unit> tellChildren <A> (A message, Schedule schedule, Func<ProcessId, bool> predicate, ProcessId sender = default(ProcessId)) Source #

Tell children the same message, delayed. The list of children to send to are filtered by the predicate provided

Parameters

param message

Message to send

param schedule

A structure that defines the method of delivery of the scheduled message

param predicate

The list of children to send to are filtered by the predicate provided

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellChildren <A> (A message, TimeSpan delayFor, Func<ProcessId, bool> predicate, ProcessId sender = default(ProcessId)) Source #

Tell children the same message, delayed. The list of children to send to are filtered by the predicate provided

Parameters

param message

Message to send

param delayFor

How long to delay sending for

param predicate

The list of children to send to are filtered by the predicate provided

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellChildren <A> (A message, DateTime delayUntil, Func<ProcessId, bool> predicate, ProcessId sender = default(ProcessId)) Source #

Tell children the same message, delayed. The list of children to send to are filtered by the predicate provided

This will fail to be accurate across a Daylight Saving Time boundary

Parameters

param message

Message to send

param delayUntil

Date and time to send

param predicate

The list of children to send to are filtered by the predicate provided

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellParent <A> (A message, ProcessId sender = default(ProcessId)) Source #

Send a message to the parent process

Parameters

param message

Message to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Eff<RT, Unit> tellParent <A> (A message, Schedule schedule, ProcessId sender = default(ProcessId)) Source #

Send a message to the parent process at a specified time in the future

Parameters

param message

Message to send

param schedule

A structure that defines the method of delivery of the scheduled message

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellParent <A> (A message, TimeSpan delayFor, ProcessId sender = default(ProcessId)) Source #

Send a message to the parent process at a specified time in the future

Parameters

param message

Message to send

param delayFor

How long to delay sending for

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellParent <A> (A message, DateTime delayUntil, ProcessId sender = default(ProcessId)) Source #

Send a message to the parent process at a specified time in the future

This will fail to be accurate across a Daylight Saving Time boundary

Parameters

param message

Message to send

param delayUntil

Date and time to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellSelf <A> (A message, ProcessId sender = default(ProcessId)) Source #

Send a message to ourself

Parameters

param message

Message to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Eff<RT, Unit> tellSelf <A> (A message, Schedule schedule, ProcessId sender = default(ProcessId)) Source #

Send a message to ourself at a specified time in the future

Parameters

param message

Message to send

param schedule

A structure that defines the method of delivery of the scheduled message

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellSelf <A> (A message, TimeSpan delayFor, ProcessId sender = default(ProcessId)) Source #

Send a message to ourself at a specified time in the future

Parameters

param message

Message to send

param delayFor

How long to delay sending for

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellSelf <A> (A message, DateTime delayUntil, ProcessId sender = default(ProcessId)) Source #

Send a message to ourself at a specified time in the future

This will fail to be accurate across a Daylight Saving Time boundary

Parameters

param message

Message to send

param delayUntil

Date and time to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Eff<RT, Unit> tellChild <A> (ProcessName name, A message, ProcessId sender = default(ProcessId)) Source #

Send a message to a named child process

Parameters

param message

Message to send

param name

Name of the child process

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Eff<RT, Unit> tellChild <A> (int index, A message, ProcessId sender = default(ProcessId)) Source #

Send a message to a child process (found by index)

Because of the potential changeable nature of child nodes, this will take the index and mod it by the number of children. We expect this call will mostly be used for load balancing, and round-robin type behaviour, so feel that's acceptable.

Parameters

param message

Message to send

param index

Index of the child process (see remarks)

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

class ProcessAssert Source #

Methods

method void CanAccept <T> (ProcessId pid, string message = null) Source #

method void HasStateTypeOf <T> (ProcessId pid, string message = null) Source #

class ProcessHub Source #

Properties

property Func<ProcessId, bool> RouteValidator Source #

Inject a function that validates incoming message destinations

Parameters

param routePredicate

Takes the To of a message and returns True if the message is allowed to pass.

property HashMap<ClientConnectionId, ClientConnection> Connections Source #

Active client connections

Methods

method ClientConnectionId OpenConnection (string remoteIp, Action<ClientMessageDTO> tell) Source #

Register a connection by ID

Parameters

param id

Client connection ID

param conn

Connection ID

method ClientConnectionId EnsureConnection (ClientConnectionId id, Action<ClientMessageDTO> tell) Source #

Keep an existing connection alive

method Unit CloseConnection (ClientConnectionId id) Source #

Register a connection by ID

Parameters

param id

Client connection ID

param conn

Connection ID

method bool TouchConnection (ClientConnectionId id) Source #

Confirm the client is still there

Parameters

param id

ID

returns

True if the connection is still active

method bool Subscribe (ClientConnectionId id, ProcessId pub, ProcessId sub) Source #

Subscribe

method bool UnSubscribe (ClientConnectionId id, ProcessId pub, ProcessId sub) Source #

Un-subscribe

struct ProcessId Source #

Process identifier

Use this to 'tell' a message to a process. It can be serialised and passed around without concerns for internals.

Fields

field ProcessId NoSender = new ProcessId() Source #

NoSender process ID

field ProcessId None = new ProcessId() Source #

None process ID

field char Sep = '/' Source #

Process ID name separator

field ProcessId Top = new ProcessId(Sep.ToString()) Source #

Absolute root of the process system

Indexers

this [ ProcessId ] Source #

Generate new ProcessId that represents a child of this process ID

Parameters

returns

Process ID

this [ ProcessId ] Source #

Generate new ProcessId that represents a child of this process ID

Parameters

returns

Process ID

Properties

property SystemName System Source #

The Process system qualifier

property string Path Source #

Absolute path of the process ID

property bool IsSelection Source #

Returns true if the ProcessId represents a selection of N process paths

property ProcessId Parent Source #

Get the parent ProcessId

Parameters

returns

Parent process ID

property bool IsValid Source #

Returns true if this is a valid process ID

property ProcessName Name Source #

Get the name of the process

Parameters

returns

Constructors

constructor ProcessId (string path) Source #

Ctor

Parameters

param path

Path of the process, in the form: /name/name/name

Methods

method Either<Exception, ProcessId> TryParse (string path) Source #

method ProcessId Child (ProcessName name) Source #

Generate new ProcessId that represents a child of this process ID

Parameters

param name

Name of the child process

returns

Process ID

method ProcessId Child (IEnumerable<ProcessId> name) Source #

Generate new ProcessId that represents a child of this process ID

Parameters

param name

Name of the child process

returns

Process ID

method IEnumerable<ProcessId> GetSelection () Source #

If this ProcessId represents a selection of N process paths then this function will return those paths as separate ProcessIds.

Parameters

returns

An enumerable of ProcessIds representing the selection. Zero ProcessIds will be returned if the ProcessId is invalid. One ProcessId will be returned if this ProcessId doesn't represent a selection.

method string ToString () Source #

Convert the ProcessId to a string

Parameters

returns

String representation of the process ID

method int GetHashCode () Source #

Hash code of process ID Do not rely on this between application sessions

Parameters

returns

Integer hash code

method bool Equals (ProcessId other) Source #

Equality check

method bool Equals (object obj) Source #

Equality check

method int CompareTo (ProcessId other) Source #

Compare

method int CompareTo (object obj) Source #

Compare

method ProcessId Skip (int count) Source #

Remove path elements from the start of the path

method ProcessId Take (int count) Source #

Take N elements of the path

method ProcessName HeadName () Source #

Accessor to the head of the path as a ProcessName

Parameters

returns

method ProcessId Head () Source #

Take head of path

method ProcessId Tail () Source #

Take tail of path

method int Count () Source #

Number of parts to the name

Parameters

returns

method ProcessId Append (ProcessId pid) Source #

Append one process ID to another

method ProcessId SetSystem (SystemName system) Source #

Set the Process system that this ProcessId belongs to

method bool StartsWith (ProcessId head) Source #

Operators

operator == (ProcessId lhs, ProcessId rhs) Source #

Equality operator

operator != (ProcessId lhs, ProcessId rhs) Source #

Non-equality operator

class ProcessIdExtensions Source #

Extensions methods for ProcessId

Methods

method HashMap<string, ProcessId> GetChildren (this ProcessId self) Source #

Get the child processes of this process

method ProcessId GetChild (this ProcessId self, ProcessName name) Source #

Get the child processes by name

method ProcessId GetChild (this ProcessId self, int index) Source #

Get the child processes by index.

Because of the potential changeable nature of child nodes, this will take the index and mod it by the number of children. We expect this call will mostly be used for load balancing, and round-robin type behaviour, so feel that's acceptable.

method ProcessId Register (this ProcessId self) Source #

Register a named process (a kind of DNS for Processes).

If the Process is visible to the cluster (PersistInbox) then the registration becomes a permanent named look-up until Process.deregister is called.

See remarks.

Multiple Processes can register under the same name. You may use a dispatcher to work on them collectively (wherever they are in the cluster). i.e.

var regd = pid.Register(name);
Dispatch.Broadcast[regd].Tell("Hello");
Dispatch.First[regd].Tell("Hello");
Dispatch.LeastBusy[regd].Tell("Hello");
Dispatch.Random[regd].Tell("Hello");
Dispatch.RoundRobin[regd].Tell("Hello");

This should be used from within a process' message loop only

Parameters

param name

Name to register under

returns

A ProcessId that allows dispatching to the process via the name. The result would look like /disp/reg/name

method ProcessId Register (this ProcessId self, ProcessName name) Source #

Register a named process (a kind of DNS for Processes).

If the Process is visible to the cluster (PersistInbox) then the registration becomes a permanent named look-up until Process.deregister is called.

See remarks.

Multiple Processes can register under the same name. You may use a dispatcher to work on them collectively (wherever they are in the cluster). i.e.

var regd = pid.Register(name);
Dispatch.Broadcast[regd].Tell("Hello");
Dispatch.First[regd].Tell("Hello");
Dispatch.LeastBusy[regd].Tell("Hello");
Dispatch.Random[regd].Tell("Hello");
Dispatch.RoundRobin[regd].Tell("Hello");

Parameters

param name

Name to register under

returns

A ProcessId that allows dispatching to the process via the name. The result would look like /disp/reg/name

method Unit Kill (this ProcessId self) Source #

Kill the process. Forces the process to shutdown. The kill message jumps ahead of any messages already in the process's queue.

method Unit Shutdown (this ProcessId self) Source #

Kill the process. Forces the process to shutdown. The kill message jumps ahead of any messages already in the process's queue.

method T Ask <T> (this ProcessId pid, object message) Source #

Ask a process for a reply

Parameters

param pid

Process to ask

param message

Message to send

returns

The response to the request

method Unit Subscribe (this ProcessId pid) Source #

Subscribes our inbox to another process publish stream. When it calls 'publish' it will arrive in our inbox.

The process can publish any number of types, any published messages not of type T will be ignored.

This should be used from within a process' message loop only

Parameters

param pid

Process to subscribe to

returns

IDisposable, call IDispose to end the subscription

method Unit Unsubscribe (this ProcessId pid) Source #

Unsubscribe from a process's publications

Parameters

param pid

Process to unsub from

method IDisposable Subscribe <T> (this ProcessId pid, IObserver<T> observer) Source #

Subscribe to the process publish stream. When a process calls 'publish' it emits messages that can be consumed using this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

Parameters

returns

IDisposable, call IDispose to end the subscription

method IDisposable Subscribe <T> (this ProcessId pid, Action<T> onNext, Action<Exception> onError, Action onComplete) Source #

Subscribe to the process publish stream. When a process calls 'publish' it emits messages that can be consumed using this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

Parameters

returns

IDisposable, call IDispose to end the subscription

method IDisposable Subscribe <T> (this ProcessId pid, Action<T> onNext, Action<Exception> onError) Source #

Subscribe to the process publish stream. When a process calls 'publish' it emits messages that can be consumed using this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

method IDisposable Subscribe <T> (this ProcessId pid, Action<T> onNext) Source #

Subscribe to the process publish stream. When a process calls 'publish' it emits messages that can be consumed using this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

method IDisposable Subscribe <T> (this ProcessId pid, Action<T> onNext, Action onComplete) Source #

Subscribe to the process publish stream. When a process calls 'publish' it emits messages that can be consumed using this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

Parameters

returns

IDisposable, call IDispose to end the subscription

method IObservable<T> Observe <T> (this ProcessId pid) Source #

Get an IObservable for a process publish stream. When a process calls 'publish' it emits messages on the observable returned by this method.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

Parameters

returns

IObservable T

method IObservable<T> ObserveState <T> (this ProcessId pid) Source #

Get an IObservable for a process's state stream. When a process state updates at the end of its message loop it announces it on the stream returned from this method. You should use this for notification only. Never modify the state object belonging to a process. Best practice is to make the state type immutable.

The process can publish any number of types, any published messages not of type T will be ignored.

Because this call is asychronous it could allow access to the message loop, therefore you can't call it from within a process message loop.

Parameters

returns

IObservable T

method Unit SubscribeState <T> (this ProcessId pid) Source #

Subscribes our inbox to another process state publish stream. When a process state updates at the end of its message loop it announces it arrives in our inbox. You should use this for notification only. Never modify the state object belonging to a process. Best practice is to make the state type immutable.

The process can publish any number of types, any published messages not of type T will be ignored. This should be used from within a process' message loop only

Parameters

returns

IObservable T

method Unit Tell <T> (this ProcessId pid, T message, ProcessId sender = default(ProcessId)) Source #

Send a message to a process

Parameters

param pid

Process ID to send to

param message

Message to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

method Unit Tell <T> (this ProcessId pid, T message, TimeSpan delayFor, ProcessId sender = default(ProcessId)) Source #

Send a message at a specified time in the future

Parameters

param pid

Process ID to send to

param message

Message to send

param delayFor

How long to delay sending for

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit Tell <T> (this ProcessId pid, T message, DateTime delayUntil, ProcessId sender = default(ProcessId)) Source #

Send a message at a specified time in the future

This will fail to be accurate across a Daylight Saving Time boundary

Parameters

param pid

Process ID to send to

param message

Message to send

param delayUntil

Date and time to send

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

method Unit Tell <T> (this ProcessId pid, T message, Echo.Schedule schedule, ProcessId sender = default(ProcessId)) Source #

Send a message at a specified time in the future

This will fail to be accurate across a Daylight Saving Time boundary

Parameters

param pid

Process ID to send to

param message

Message to send

param schedule

A structure that defines the method of delivery of the scheduled message

param sender

Optional sender override. The sender is handled automatically if you do not provide one.

returns

IDisposable that you can use to cancel the operation if necessary. You do not need to call Dispose for any other reason.

class ProcessLogItem Source #

Fields

field DateTime When Source #

field ProcessLogItemType Type Source #

field Option<string> Message Source #

field Option<Exception> Exception Source #

Properties

property string TypeDisplay Source #

property string DateDisplay Source #

Constructors

constructor ProcessLogItem (ProcessLogItemType type, string message, Exception exception) Source #

constructor ProcessLogItem (ProcessLogItemType type, string message) Source #

constructor ProcessLogItem (ProcessLogItemType type, Exception exception) Source #

Methods

method string ToString () Source #

struct ProcessName Source #

Name of a Process in LanguageExt.Process system.

It enforces the rules for process names. Process have the same rules as file-names in windows.

Properties

property bool IsValid Source #

property bool IsSelection Source #

Constructors

constructor ProcessName (string value) Source #

Ctor

Parameters

param value

Process name

Methods

method Either<Exception, ProcessName> TryParse (string value) Source #

method ProcessName FromSelection (IEnumerable<ProcessId> pids) Source #

method IEnumerable<ProcessId> GetSelection () Source #

method string ToString () Source #

method int GetHashCode () Source #

method bool Equals (ProcessName other) Source #

method int CompareTo (ProcessName other) Source #

method int CompareTo (object obj) Source #

method bool Equals (object obj) Source #

Operators

operator == (ProcessName lhs, ProcessName rhs) Source #

operator != (ProcessName lhs, ProcessName rhs) Source #

class Role Source #

Each node in the cluster has a role name and at all times the cluster-nodes have a list of the alive nodes and their roles (Process.ClusterNodes). Nodes are removed from Process.ClusterNodes if they don't phone in. Process.ClusterNodes is at most 3 seconds out-of-date and can therefore be used to reliably find out which nodes are available and what roles they do.

By using Role.First, Role.Broadcast, Role.LeastBusy, Role.Random and Role.RoundRobin you can build a ProcessId that is resolved at the time of doing a 'tell', 'ask', 'subscribe', etc. This can allow reliable messaging to Processes in the cluster.

Fields

field ProcessId Broadcast Source #

A ProcessId that represents a set of nodes in a cluster. When used for operations like 'tell', the message is dispatched to all nodes in the set. See remarks.

You may create a reference to child nodes in the usual way: Role.Broadcast["my-role"]["user"]["child-1"][...]

Examples

tell( Role.Broadcast["message-role"]["user"]["message-log"], "Hello" );

field ProcessId LeastBusy Source #

A ProcessId that represents a set of nodes in a cluster. When used for operations like 'tell', the message is dispatched to the least busy from the set. See remarks.

You may create a reference to child nodes in the usual way: Role.LeastBusy["my-role"]["user"]["child-1"][...]

Examples

tell( Role.LeastBusy["message-role"]["user"]["message-log"], "Hello" );

field ProcessId Random Source #

A ProcessId that represents a set of nodes in a cluster. When used for operations like 'tell', the message is dispatched to a cryptographically random node from the set. See remarks.

You may create a reference to child nodes in the usual way: Role.Random["my-role"]["user"]["child-1"][...]

Examples

tell( Role.Random["message-role"]["user"]["message-log"], "Hello" );

field ProcessId RoundRobin Source #

A ProcessId that represents a set of nodes in a cluster. When used for operations like 'tell', the message is dispatched to the nodes in a round- robin fashion See remarks.

You may create a reference to child nodes in the usual way: Role.RoundRobin["my-role"]["user"]["child-1"][...]

Examples

tell( Role.RoundRobin["message-role"]["user"]["message-log"], "Hello" );

field ProcessId First Source #

A ProcessId that represents a set of nodes in a cluster. When used for operations like 'tell', the node names are sorted in ascending order and the message is dispatched to the first one. This can be used for leader election for example. See remarks.

You may create a reference to child nodes in the usual way: Role.First["my-role"]["user"]["child-1"][...]

Examples

tell( Role.First["message-role"]["user"]["message-log"], "Hello" );

field ProcessId Second Source #

A ProcessId that represents a set of nodes in a cluster. When used for operations like 'tell', the node names are sorted in ascending order and the message is dispatched to the second one. See remarks.

You may create a reference to child nodes in the usual way: Role.Second["my-role"]["user"]["child-1"][...]

Examples

tell( Role.Second["message-role"]["user"]["message-log"], "Hello" );

field ProcessId Third Source #

A ProcessId that represents a set of nodes in a cluster. When used for operations like 'tell', the node names are sorted in ascending order and the message is dispatched to the third one. See remarks.

You may create a reference to child nodes in the usual way: Role.Third["my-role"]["user"]["child-1"][...]

Examples

tell( Role.Third["message-role"]["user"]["message-log"], "Hello" );

field ProcessId Last Source #

A ProcessId that represents a set of nodes in a cluster. When used for operations like 'tell', the node names are sorted in descending order and the message is dispatched to the first one. See remarks.

You may create a reference to child nodes in the usual way: Role.Last["my-role"]["user"]["child-1"][...]

Examples

tell( Role.Last["message-role"]["user"]["message-log"], "Hello" );

Properties

property ProcessName Current Source #

The role that this node is a part of

Methods

method ProcessId Next (SystemName system = default(SystemName)) Source #

Builds a ProcessId that represents the next node in the role that this node is a part of. If there is only one node in the role then any messages sent will be sent to the leaf-process with itself. Unlike other Roles, you do not specify the role-name as the first child. See remarks.

You may create a reference to child nodes in the usual way: Role.Next["user"]["child-1"][...]

Examples

tell( Role.Next["user"]["message-log"], "Hello" );

method ProcessId Prev (SystemName system = default(SystemName)) Source #

Builds a ProcessId that represents the previous node in the role that this node is a part of. If there is only one node in the role then any messages sent will be sent to the leaf-process with itself. Unlike other Roles, you do not specify the role-name as the first child. See remarks.

You may create a reference to child nodes in the usual way: Role.Prev["user"]["child-1"][...]

Examples

tell( Role.Prev["user"]["message-log"], "Hello" );

method IEnumerable<ProcessId> NodeIds (ProcessId leaf) Source #

method HashMap<ProcessName, ClusterNode> Nodes (ProcessId leaf, SystemName system = default(SystemName)) Source #

class Router Source #

Methods

method ProcessId broadcast <S, T> ( ProcessName Name, int Count, Func<S> Setup, Func<S, T, S> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is sent to all worker processes

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId broadcast <T> ( ProcessName Name, IEnumerable<ProcessId> Workers, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with that routes each message to the Workers in a round robin fashion.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Flags

Process flags

returns

Process ID of the delegator process

method ProcessId broadcastMap <S, T, U> ( ProcessName Name, int Count, Func<S> Setup, Func<S, U, S> Inbox, Func<T, U> Map, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is sent to all worker processes

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Map

Message mapping function

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId broadcastMap <T, U> ( ProcessName Name, IEnumerable<ProcessId> Workers, Func<T,U> Map, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with that routes each message to all workers Each message is mapped before being broadcast.

Parameters

type S

State type

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Map

Message mapping function

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId broadcastMapMany <S, T, U> ( ProcessName Name, int Count, Func<S> Setup, Func<S, U, S> Inbox, Func<T, IEnumerable<U>> MapMany, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with N worker processes, each message is mapped from T to IEnumerable U before each resulting Us are passed all of the worker processes.

Parameters

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Count

Number of worker processes

param map

Maps the message from T to IEnumerable U before each one is passed to the workers

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId broadcastMapMany <T, U> ( ProcessName Name, IEnumerable<ProcessId> Workers, Func<T, IEnumerable<U>> MapMany, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with N worker processes, each message is mapped from T to IEnumerable U before each resulting Us are passed all of the worker processes.

Parameters

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Count

Number of worker processes

param map

Maps the message from T to IEnumerable U before each one is passed to the workers

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId broadcast <T> ( ProcessName Name, int Count, Action<T> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is sent to one worker process in a round robin fashion.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId broadcastMap <T, U> ( ProcessName Name, int Count, Action<U> Inbox, Func<T, U> Map, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is mapped and sent to one worker process in a round robin fashion.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId broadcastMapMany <T, U> ( ProcessName Name, int Count, Action<U> Inbox, Func<T, IEnumerable<U>> MapMany, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with N worker processes, each message is mapped from T to IEnumerable U before each resulting U is passed to the worker processes in a round robin fashion.

Parameters

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Count

Number of worker processes

param map

Maps the message from T to IEnumerable U before each one is passed to the workers

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

class Router Source #

Methods

method Func<int, TMsg, int> DefaultHashFunction <TMsg> () Source #

Default hashing function, used by the hashing routers by default if no HashFunc parameter is provided. The function turns a worker-count and message into a worker index

Parameters

type TMsg

Message type

returns

Function that turns a worker-count and message into a worker index

method ProcessId hash <S, T> ( ProcessName Name, int Count, Func<S> Setup, Func<S, T, S> Inbox, Func<int, T, int> HashFunc = null, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is sent to a worker process by calling GetHashCode on the message and modding by the number of workers, the result is used as the worker index to route to.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId hash <T> ( ProcessName Name, IEnumerable<ProcessId> Workers, Func<int, T, int> HashFunc = null, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with that routes each message by calling GetHashCode on the message and modding by the number of workers and using that as the worker index to route to.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId hashMap <S, T, U> ( ProcessName Name, int Count, Func<S> Setup, Func<S, U, S> Inbox, Func<T, U> Map, Func<int, T, int> HashFunc = null, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is sent to a worker process by calling GetHashCode on the message and modding by the number of workers and using that to find the worker index to route to.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId hashMap <T, U> ( ProcessName Name, IEnumerable<ProcessId> Workers, Func<T, U> Map, Func<int, U, int> HashFunc = null, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process where each message is sent to a worker process by calling GetHashCode on the mapped message and modding it by the number of workers to find the worker index to route to.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId hashMapMany <S, T, U> ( ProcessName Name, int Count, Func<S> Setup, Func<S, U, S> Inbox, Func<T, IEnumerable<U>> MapMany, Func<int, U, int> HashFunc = null, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with N worker processes, each message is mapped from T to IEnumerable U before each resulting U is passed to the worker processes by getting each mapped message and calling GetHashCode and modding by the number of workers to find the worker index to route to.

Parameters

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Count

Number of worker processes

param map

Maps the message from T to IEnumerable U before each one is passed to the workers

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId hashMapMany <T, U> ( ProcessName Name, IEnumerable<ProcessId> Workers, Func<T, IEnumerable<U>> MapMany, Func<int, U, int> HashFunc = null, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with N worker processes, each message is mapped from T to IEnumerable U before each resulting U is passed to the worker processes by getting each mapped message and calling GetHashCode and modding by the number of workers to find the worker index to route to.

Parameters

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Count

Number of worker processes

param map

Maps the message from T to IEnumerable U before each one is passed to the workers

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId hash <T> ( ProcessName Name, int Count, Action<T> Inbox, Func<int, T, int> HashFunc = null, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with that routes each message by calling GetHashCode on the message and modding by the number of workers and using that as the worker index to route to.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId hashMap <T, U> ( ProcessName Name, int Count, Action<U> Inbox, Func<T, U> Map, Func<int, T, int> HashFunc = null, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process where each message is sent to a worker process by calling GetHashCode on the mapped message and modding it by the number of workers to find the worker index to route to.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId hashMapMany <T, U> ( ProcessName Name, int Count, Action<U> Inbox, Func<T, IEnumerable<U>> MapMany, Func<int, U, int> HashFunc = null, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with N worker processes, each message is mapped from T to IEnumerable U before each resulting U is passed to the worker processes by getting each mapped message and calling GetHashCode and modding by the number of workers to find the worker index to route to.

Parameters

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Count

Number of worker processes

param map

Maps the message from T to IEnumerable U before each one is passed to the workers

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

class Router Source #

Methods

method ProcessId leastBusy <S, T> ( ProcessName Name, int Count, Func<S> Setup, Func<S, T, S> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is sent to the least busy worker.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId leastBusy <T> ( ProcessName Name, IEnumerable<ProcessId> Workers, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with that routes each message to the least busy worker.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId leastBusyMap <S, T, U> ( ProcessName Name, int Count, Func<S> Setup, Func<S, U, S> Inbox, Func<T, U> Map, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is mapped and sent to the least busy worker

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId leastBusyMap <T, U> ( ProcessName Name, IEnumerable<ProcessId> Workers, Func<T, U> Map, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with that routes each message is mapped and sent to the least busy worker

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId leastBusy <T> ( ProcessName Name, int Count, Action<T> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is sent to the least busy worker.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId leastBusyMap <T, U> ( ProcessName Name, int Count, Action<U> Inbox, Func<T, U> Map, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is mapped and sent to the least busy worker.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

class Router Source #

Methods

method ProcessId random <S, T> ( ProcessName Name, int Count, Func<S> Setup, Func<S, T, S> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is sent to one worker process randomly.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId random <T> ( ProcessName Name, IEnumerable<ProcessId> Workers, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with that routes each message to the Workers randomly.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId randomMap <S, T, U> ( ProcessName Name, int Count, Func<S> Setup, Func<S, U, S> Inbox, Func<T, U> Map, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is sent to one worker process randomly.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId randomMap <T, U> ( ProcessName Name, IEnumerable<ProcessId> Workers, Func<T, U> Map, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with that routes each message to the Workers randomly.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId randomMapMany <S, T, U> ( ProcessName Name, int Count, Func<S> Setup, Func<S, U, S> Inbox, Func<T, IEnumerable<U>> MapMany, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with N worker processes, each message is mapped from T to IEnumerable U before each resulting U is passed to the worker processes randomly.

Parameters

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Count

Number of worker processes

param map

Maps the message from T to IEnumerable U before each one is passed to the workers

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId randomMapMany <T, U> ( ProcessName Name, IEnumerable<ProcessId> Workers, Func<T, IEnumerable<U>> MapMany, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with N worker processes, each message is mapped from T to IEnumerable U before each resulting U is passed to the worker processes randomly.

Parameters

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Count

Number of worker processes

param map

Maps the message from T to IEnumerable U before each one is passed to the workers

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId random <T> ( ProcessName Name, int Count, Action<T> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is sent to one worker process in a round robin fashion.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId randomMap <T, U> ( ProcessName Name, int Count, Action<U> Inbox, Func<T, U> Map, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is mapped and sent to one worker process in a round robin fashion.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId randomMapMany <T, U> ( ProcessName Name, int Count, Action<U> Inbox, Func<T, IEnumerable<U>> MapMany, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with N worker processes, each message is mapped from T to IEnumerable U before each resulting U is passed to the worker processes in a round robin fashion.

Parameters

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Count

Number of worker processes

param map

Maps the message from T to IEnumerable U before each one is passed to the workers

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

class Router Source #

Methods

method ProcessId roundRobin <S, T> ( ProcessName Name, int Count, Func<S> Setup, Func<S, T, S> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is sent to one worker process in a round robin fashion.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId roundRobin <T> ( ProcessName Name, IEnumerable<ProcessId> Workers, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with that routes each message to the Workers in a round robin fashion.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId roundRobinMap <S, T, U> ( ProcessName Name, int Count, Func<S> Setup, Func<S, U, S> Inbox, Func<T, U> Map, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is mapped and sent to one worker process in a round robin fashion.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId roundRobinMap <T, U> ( ProcessName Name, IEnumerable<ProcessId> Workers, Func<T, U> Map, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with that routes each message is mapped and sent to the Workers in a round robin fashion.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId roundRobinMapMany <S, T, U> ( ProcessName Name, int Count, Func<S> Setup, Func<S, U, S> Inbox, Func<T, IEnumerable<U>> MapMany, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with N worker processes, each message is mapped from T to IEnumerable U before each resulting U is passed to the worker processes in a round robin fashion.

Parameters

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Count

Number of worker processes

param map

Maps the message from T to IEnumerable U before each one is passed to the workers

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId roundRobinMapMany <T, U> ( ProcessName Name, IEnumerable<ProcessId> Workers, Func<T, IEnumerable<U>> MapMany, RouterOption Options = RouterOption.Default, ProcessFlags Flags = ProcessFlags.Default, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize ) Source #

Spawns a new process with N worker processes, each message is mapped from T to IEnumerable U before each resulting U is passed to the worker processes in a round robin fashion.

Parameters

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Count

Number of worker processes

param map

Maps the message from T to IEnumerable U before each one is passed to the workers

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId roundRobin <T> ( ProcessName Name, int Count, Action<T> Inbox, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is sent to one worker process in a round robin fashion.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId roundRobinMap <T, U> ( ProcessName Name, int Count, Action<U> Inbox, Func<T, U> Map, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with Count worker processes, each message is mapped and sent to one worker process in a round robin fashion.

Parameters

type S

State type

type T

Message type

param Name

Delegator process name

param Count

Number of worker processes

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

method ProcessId roundRobinMapMany <T, U> ( ProcessName Name, int Count, Action<U> Inbox, Func<T, IEnumerable<U>> MapMany, ProcessFlags Flags = ProcessFlags.Default, State<StrategyContext, Unit> Strategy = null, int MaxMailboxSize = ProcessSetting.DefaultMailboxSize, string WorkerName = "worker" ) Source #

Spawns a new process with N worker processes, each message is mapped from T to IEnumerable U before each resulting U is passed to the worker processes in a round robin fashion.

Parameters

type T

Message type

type U

Mapped message type

param Name

Delegator process name

param Count

Number of worker processes

param map

Maps the message from T to IEnumerable U before each one is passed to the workers

param Inbox

Worker message handler

param Flags

Process flags

param Strategy

Failure supervision strategy

returns

Process ID of the delegator process

class Router Source #

Methods

method ProcessId fromConfig <T> (ProcessName name) Source #

Spawn a router using the settings in the config

Parameters

param name

Name of the child process that will be the router

returns

ProcessId of the router

Examples

router broadcast1:
    pid:			/root/user/broadcast1
    route:	        broadcast
    worker-count:	10

router broadcast2:
    pid:			/root/user/broadcast2
    route:	        broadcast
    workers:		[hello, world]

router least:
    pid:			/role/user/least
    route:	        least-busy
    workers:		[one, two, three]

method ProcessId fromConfig <T> (ProcessName name, Func<T, Unit> Inbox) Source #

Spawn a router using the settings in the config

Parameters

type T
param name

Name of the child process that will be the router

returns

ProcessId of the router

Examples

router broadcast1:
    pid:			/root/user/broadcast1
    route:	        broadcast
    worker-count:	10

router broadcast2:
    pid:			/root/user/broadcast2
    route:	        broadcast
    workers:		[hello, world]

router least:
    pid:			/role/user/least
    route:	        least-busy
    workers:		[one, two, three]

method ProcessId fromConfig <T> (ProcessName name, Action<T> Inbox) Source #

Spawn a router using the settings in the config

Parameters

type T
param name

Name of the child process that will be the router

returns

ProcessId of the router

Examples

router broadcast1:
    pid:			/root/user/broadcast1
    route:	        broadcast
    worker-count:	10

router broadcast2:
    pid:			/root/user/broadcast2
    route:	        broadcast
    workers:		[hello, world]

router least:
    pid:			/role/user/least
    route:	        least-busy
    workers:		[one, two, three]

method ProcessId fromConfig <S, T> (ProcessName name, Func<S> Setup, Func<S,T,S> Inbox) Source #

Spawn a router using the settings in the config

Parameters

type T
param name

Name of the child process that will be the router

returns

ProcessId of the router

Examples

router broadcast1:
    pid:			/root/user/broadcast1
    route:	        broadcast
    worker-count:	10

router broadcast2:
    pid:			/root/user/broadcast2
    route:	        broadcast
    workers:		[hello, world]

router least:
    pid:			/role/user/least
    route:	        least-busy
    workers:		[one, two, three]

class Schedule Source #

Fields

field DateTime Due Source #

field string Key Source #

field PersistenceType Type Source #

field Func<object, object, object> Fold Source #

field object Zero Source #

Methods

method Schedule SetDue (DateTime due) Source #

method Schedule SetKey (string key) Source #

method Schedule MakeEphemeral () Source #

method Schedule MakePersistent () Source #

method Schedule Persistent (DateTime due) Source #

method Schedule Ephemeral (DateTime due) Source #

method Schedule Persistent (TimeSpan due) Source #

method Schedule Ephemeral (TimeSpan due) Source #

method Schedule Persistent (DateTime due, string key) Source #

method Schedule Ephemeral (DateTime due, string key) Source #

method Schedule Persistent (TimeSpan due, string key) Source #

method Schedule Ephemeral (TimeSpan due, string key) Source #

method Schedule PersistentAppend <MonoidA, A> (DateTime due, string key) Source #

where MonoidA : struct, Monoid<A>

method Schedule EphemeralAppend <MonoidA, A> (DateTime due, string key) Source #

where MonoidA : struct, Monoid<A>

method Schedule PersistentAppend <MonoidA, A> (TimeSpan due, string key) Source #

where MonoidA : struct, Monoid<A>

method Schedule EphemeralAppend <MonoidA, A> (TimeSpan due, string key) Source #

where MonoidA : struct, Monoid<A>

method Schedule PersistentFold <S, A> (DateTime due, string key, S state, Func<S, A, S> f) Source #

method Schedule EphemeralFold <S, A> (DateTime due, string key, S state, Func<S, A, S> f) Source #

method Schedule PersistentFold <S, A> (TimeSpan due, string key, S state, Func<S, A, S> f) Source #

method Schedule EphemeralFold <S, A> (TimeSpan due, string key, S state, Func<S, A, S> f) Source #

struct SessionId Source #

Session ID

It enforces the rules for session IDs.

Fields

field string Value Source #

Properties

property bool IsValid Source #

Constructors

constructor SessionId (string value) Source #

Ctor

Parameters

param value

SessionId

Methods

method SessionId Generate (int sizeInBytes = DefaultSessionIdSizeInBytes) Source #

Make a cryptographically strong session ID

Parameters

param sizeInBytes

Size in bytes. This is not the final string length, the final length depends on the Base64 encoding of a byte-array sizeInBytes long. As a guide a 64 byte session ID turns into an 88 character string.

method string ToString () Source #

method int GetHashCode () Source #

method bool Equals (SessionId other) Source #

method int CompareTo (SessionId other) Source #

method int CompareTo (object obj) Source #

method bool Equals (object obj) Source #

Operators

operator == (SessionId lhs, SessionId rhs) Source #

operator != (SessionId lhs, SessionId rhs) Source #

struct SupplementarySessionId Source #

Supplementary Session ID

It enforces the rules for session IDs.

Fields

field string Key = "sys-supp-session" Source #

Hashfield key for supplementary sessionid

field string Value Source #

Properties

property bool IsValid Source #

Constructors

constructor SupplementarySessionId (string value) Source #

Ctor

Parameters

param value

SupplementarySessionId

Methods

method SupplementarySessionId Generate (int sizeInBytes = DefaultSessionIdSizeInBytes) Source #

Make a cryptographically strong session ID

Parameters

param sizeInBytes

Size in bytes. This is not the final string length, the final length depends on the Base64 encoding of a byte-array sizeInBytes long. As a guide a 64 byte session ID turns into an 88 character string.

method string ToString () Source #

method int GetHashCode () Source #

method SupplementarySessionId New (string value) Source #

method bool Equals (SupplementarySessionId other) Source #

method int CompareTo (SupplementarySessionId other) Source #

method int CompareTo (object obj) Source #

method bool Equals (object obj) Source #

Operators

operator == (SupplementarySessionId lhs, SupplementarySessionId rhs) Source #

operator != (SupplementarySessionId lhs, SupplementarySessionId rhs) Source #

struct SystemName Source #

Name of a Process System in LanguageExt.Process system.

It enforces the rules for system names. SystemNames have the same rules as file-names in windows.

Properties

property string Value Source #

property bool IsValid Source #

Constructors

constructor SystemName (string value) Source #

Ctor

Parameters

param value

Process name

Methods

method Either<Exception, SystemName> TryParse (string value) Source #

method string ToString () Source #

method int GetHashCode () Source #

method bool Equals (SystemName other) Source #

method int CompareTo (SystemName other) Source #

method int CompareTo (object obj) Source #

method bool Equals (object obj) Source #

Operators

operator == (SystemName lhs, SystemName rhs) Source #

operator != (SystemName lhs, SystemName rhs) Source #