component

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 23, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//The ONE_FOR_ONE_STRATEGY indicates that a Supervisor should only
	//restart the quacktors.Actor that went down when a quacktors.Actor
	//has quit or was killed.
	ONE_FOR_ONE_STRATEGY strategy = iota

	//The ALL_FOR_ONE_STRATEGY indicates that a Supervisor should
	//restart all of its actors when a quacktors.Actor has quit or was killed.
	ALL_FOR_ONE_STRATEGY

	//The FAIL_ALL_STRATEGY indicates that a Supervisor should kill all other
	//actors and then itself when a quacktors.Actor has quit or was killed.
	FAIL_ALL_STRATEGY
)

Variables

This section is empty.

Functions

func DynamicSupervisor added in v0.0.5

func DynamicSupervisor(strategy strategy, actors []quacktors.Actor) *dynamicSupervisorComponent

DynamicSupervisor returns a dynamic supervisor component. It is functionally the same as the Supervisor with the key difference being that child actors of the dynamic supervisor don't use named actors but can be addressed via PIDs (internally it still uses named actors but automatically creates and manages relays for each child).

func Link(from *quacktors.Pid, to *quacktors.Pid) quacktors.Actor

Link links two PIDs together, so when one goes down, the other one does too.

func LoadBalancer added in v0.0.5

func LoadBalancer(threshold uint16, actor quacktors.Actor, usageFunction func() uint16) quacktors.Actor

LoadBalancer creates a load balancer component from the provided parameters. The load balancer scales an actor according to usage determined by the usage function and the scaling threshold. If one actor in the pool goes down, it is automatically restarted if needed. At least one instance of the actor has to be always running. The scaling of the actor is calculated by a threshold function. If the load balancer is killed, it takes down all of the actors in its pool so to avoid actor leaks.

Threshold function

The threshold function is defined like so:

f(u,t) = max(1, (\lfloor {\frac{u - (t/2)}_{t}} \rfloor) + 1)

Where `u` is the usage and `t` is the threshold and the function domain is u >= 0 and t >= 1.

func Relay

func Relay(pidName string) quacktors.Actor

Relay returns a quacktors.Actor that forwards messages to a named actor.

func Supervisor

func Supervisor(strategy strategy, actors map[string]quacktors.Actor) quacktors.Actor

Supervisor returns a quacktors.Actor that supervises other actors by some strategy.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL