Documentation ¶
Index ¶
- Constants
- func DynamicSupervisor(strategy strategy, actors []quacktors.Actor) *dynamicSupervisorComponent
- func Link(from *quacktors.Pid, to *quacktors.Pid) quacktors.Actor
- func LoadBalancer(threshold uint16, actor quacktors.Actor, usageFunction func() uint16) quacktors.Actor
- func Relay(pidName string) quacktors.Actor
- func Supervisor(strategy strategy, actors map[string]quacktors.Actor) quacktors.Actor
Constants ¶
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
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 ¶ added in v0.0.4
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.
Types ¶
This section is empty.