Documentation
¶
Index ¶
- Variables
- type Actor
- func (a *Actor) HandleCall(from gen.PID, ref gen.Ref, request any) (any, error)
- func (a *Actor) HandleCallAlias(alias gen.Alias, from gen.PID, ref gen.Ref, request any) (any, error)
- func (a *Actor) HandleCallName(name gen.Atom, from gen.PID, ref gen.Ref, request any) (any, error)
- func (a *Actor) HandleEvent(message gen.MessageEvent) error
- func (a *Actor) HandleInspect(from gen.PID, item ...string) map[string]string
- func (a *Actor) HandleLog(message gen.MessageLog) error
- func (a *Actor) HandleMessage(from gen.PID, message any) error
- func (a *Actor) HandleMessageAlias(alias gen.Alias, from gen.PID, message any) error
- func (a *Actor) HandleMessageName(name gen.Atom, from gen.PID, message any) error
- func (a *Actor) Init(args ...any) error
- func (a *Actor) ProcessInit(process gen.Process, args ...any) (rr error)
- func (a *Actor) ProcessRun() (rr error)
- func (a *Actor) ProcessTerminate(reason error)
- func (a *Actor) SetSplitHandle(split bool)
- func (a *Actor) SetTrapExit(trap bool)
- func (a *Actor) SplitHandle() bool
- func (a *Actor) Terminate(reason error)
- func (a *Actor) TrapExit() bool
- type ActorBehavior
- type Pool
- func (p *Pool) AddWorkers(n int) (int64, error)
- func (p *Pool) HandleCall(from gen.PID, ref gen.Ref, request any) (any, error)
- func (p *Pool) HandleEvent(message gen.MessageEvent) error
- func (p *Pool) HandleInspect(from gen.PID, item ...string) map[string]string
- func (p *Pool) HandleMessage(from gen.PID, message any) error
- func (p *Pool) ProcessInit(process gen.Process, args ...any) (rr error)
- func (p *Pool) ProcessRun() (rr error)
- func (p *Pool) ProcessTerminate(reason error)
- func (p *Pool) RemoveWorkers(n int) (int64, error)
- func (p *Pool) Terminate(reason error)
- type PoolBehavior
- type PoolOptions
- type Supervisor
- func (s *Supervisor) AddChild(child SupervisorChildSpec) error
- func (s *Supervisor) Children() []SupervisorChild
- func (s *Supervisor) DisableChild(name gen.Atom) error
- func (s *Supervisor) EnableChild(name gen.Atom) error
- func (s *Supervisor) HandleCall(from gen.PID, ref gen.Ref, request any) (any, error)
- func (s *Supervisor) HandleChildStart(name gen.Atom, pid gen.PID) error
- func (s *Supervisor) HandleChildTerminate(name gen.Atom, pid gen.PID, reason error) error
- func (s *Supervisor) HandleEvent(message gen.MessageEvent) error
- func (s *Supervisor) HandleInspect(from gen.PID, item ...string) map[string]string
- func (s *Supervisor) HandleMessage(from gen.PID, message any) error
- func (s *Supervisor) ProcessInit(process gen.Process, args ...any) (rr error)
- func (s *Supervisor) ProcessRun() (rr error)
- func (s *Supervisor) ProcessTerminate(reason error)
- func (s *Supervisor) StartChild(name gen.Atom, args ...any) error
- func (s *Supervisor) Terminate(reason error)
- type SupervisorBehavior
- type SupervisorChild
- type SupervisorChildSpec
- type SupervisorRestart
- type SupervisorSpec
- type SupervisorStrategy
- type SupervisorType
- type WebWorker
- func (w *WebWorker) HandleCall(from gen.PID, ref gen.Ref, request any) (any, error)
- func (w *WebWorker) HandleDelete(from gen.PID, writer http.ResponseWriter, request *http.Request) error
- func (w *WebWorker) HandleEvent(message gen.MessageEvent) error
- func (w *WebWorker) HandleGet(from gen.PID, writer http.ResponseWriter, request *http.Request) error
- func (w *WebWorker) HandleHead(from gen.PID, writer http.ResponseWriter, request *http.Request) error
- func (w *WebWorker) HandleInspect(from gen.PID, item ...string) map[string]string
- func (w *WebWorker) HandleMessage(from gen.PID, message any) error
- func (w *WebWorker) HandleOptions(from gen.PID, writer http.ResponseWriter, request *http.Request) error
- func (w *WebWorker) HandlePatch(from gen.PID, writer http.ResponseWriter, request *http.Request) error
- func (w *WebWorker) HandlePost(from gen.PID, writer http.ResponseWriter, request *http.Request) error
- func (w *WebWorker) HandlePut(from gen.PID, writer http.ResponseWriter, request *http.Request) error
- func (w *WebWorker) Init(args ...any) error
- func (w *WebWorker) ProcessInit(process gen.Process, args ...any) (rr error)
- func (w *WebWorker) ProcessRun() (rr error)
- func (w *WebWorker) ProcessTerminate(reason error)
- func (w *WebWorker) Terminate(reason error)
- type WebWorkerBehavior
Constants ¶
This section is empty.
Variables ¶
var ( ErrSupervisorStrategyActive = errors.New("supervisor strategy is active") ErrSupervisorChildUnknown = errors.New("unknown child") ErrSupervisorChildRunning = errors.New("child process is already running") ErrSupervisorChildDisabled = errors.New("child is disabled") ErrSupervisorRestartsExceeded = errors.New("restart intensity is exceeded") ErrSupervisorChildDuplicate = errors.New("duplicate child spec Name") ErrPoolEmpty = errors.New("no worker process in the pool") )
Functions ¶
This section is empty.
Types ¶
type Actor ¶
Actor implementats ProcessBehavior interface and provides callbacks for - initialization - handling messages/requests. - termination All callbacks of the ActorBehavior are optional for the implementation.
func (*Actor) HandleCall ¶
func (*Actor) HandleCallAlias ¶
func (*Actor) HandleCallName ¶
func (*Actor) HandleEvent ¶
func (a *Actor) HandleEvent(message gen.MessageEvent) error
func (*Actor) HandleInspect ¶
func (*Actor) HandleMessageAlias ¶
func (*Actor) HandleMessageName ¶
func (*Actor) ProcessInit ¶
ProcessInit
func (*Actor) ProcessRun ¶
func (*Actor) ProcessTerminate ¶
func (*Actor) SetSplitHandle ¶
SetSplitHandle enables/disables splitting invoke callback depending on the target type. Enabled splitting makes this process to invoke
- HandleCall/HandleMessage for the request/message addressed by gen.PID
- HandleCallName/HandleMessageName for the request/message addressed by gen.ProcessID
- HandleCallAlias/HandleMessageAlias for the request/message addressed by gen.Alias
func (*Actor) SetTrapExit ¶
SetTrapExit enables/disables the trap on exit requests sent by SendExit(...). Enabled trap makes the actor ignore such requests transforming them into regular messages (gen.MessageExitPID) except for the request from the parent process with the reason gen.TerminateReasonShutdown. With disabled trap, actor gracefully terminates by invoking Terminate callback with the given reason
func (*Actor) SplitHandle ¶
SplitHandle returns whether the splitting was enabled on this actor
type ActorBehavior ¶
type ActorBehavior interface { gen.ProcessBehavior // Init invoked on a spawn Actor for the initializing. Init(args ...any) error // HandleMessage invoked if Actor received a message sent with gen.Process.Send(...). // Non-nil value of the returning error will cause termination of this process. // To stop this process normally, return gen.TerminateReasonNormal // or any other for abnormal termination. HandleMessage(from gen.PID, message any) error // HandleCall invoked if Actor got a synchronous request made with gen.Process.Call(...). // Return nil as a result to handle this request asynchronously and // to provide the result later using the gen.Process.SendResponse(...) method. HandleCall(from gen.PID, ref gen.Ref, request any) (any, error) // Terminate invoked on a termination process Terminate(reason error) // HandleMessageName invoked if split handling was enabled using SetSplitHandle(true) // and message has been sent by name HandleMessageName(name gen.Atom, from gen.PID, message any) error HandleMessageAlias(alias gen.Alias, from gen.PID, message any) error HandleCallName(name gen.Atom, from gen.PID, ref gen.Ref, request any) (any, error) HandleCallAlias(alias gen.Alias, from gen.PID, ref gen.Ref, request any) (any, error) // HandleLog invoked on a log message if this process was added as a logger. HandleLog(message gen.MessageLog) error // HandleEvent invoked on an event message if this process got subscribed on // this event using gen.Process.LinkEvent or gen.Process.MonitorEvent HandleEvent(message gen.MessageEvent) error // HandleInspect invoked on the request made with gen.Process.Inspect(...) HandleInspect(from gen.PID, item ...string) map[string]string }
ActorBehavior interface
type Pool ¶
func (*Pool) HandleCall ¶
func (*Pool) HandleEvent ¶
func (p *Pool) HandleEvent(message gen.MessageEvent) error
func (*Pool) HandleInspect ¶
func (*Pool) ProcessRun ¶
func (*Pool) ProcessTerminate ¶
type PoolBehavior ¶
type PoolBehavior interface { gen.ProcessBehavior // Init invoked on a spawn Pool for the initializing. Init(args ...any) (PoolOptions, error) // HandleMessage invoked if Pool received a message sent with gen.Process.Send(...). // Non-nil value of the returning error will cause termination of this process. // To stop this process normally, return gen.TerminateReasonNormal // or any other for abnormal termination. HandleMessage(from gen.PID, message any) error // HandleCall invoked if Pool got a synchronous request made with gen.Process.Call(...). // Return nil as a result to handle this request asynchronously and // to provide the result later using the gen.Process.SendResponse(...) method. HandleCall(from gen.PID, ref gen.Ref, request any) (any, error) // Terminate invoked on a termination process Terminate(reason error) // HandleEvent invoked on an event message if this process got subscribed on // this event using gen.Process.LinkEvent or gen.Process.MonitorEvent HandleEvent(message gen.MessageEvent) error // HandleInspect invoked on the request made with gen.Process.Inspect(...) HandleInspect(from gen.PID, item ...string) map[string]string }
type PoolOptions ¶
type PoolOptions struct { WorkerMailboxSize int64 PoolSize int64 WorkerFactory gen.ProcessFactory WorkerArgs []any }
type Supervisor ¶
func (*Supervisor) AddChild ¶
func (s *Supervisor) AddChild(child SupervisorChildSpec) error
AddChild allows add a new child to the supervisor. Returns error if spawning child process is failed.
func (*Supervisor) Children ¶
func (s *Supervisor) Children() []SupervisorChild
Children returns a list of supervisor children processes
func (*Supervisor) DisableChild ¶
func (s *Supervisor) DisableChild(name gen.Atom) error
DisableChild stops the child process with gen.TerminateReasonShutdown and disables it in the supervisor spec.
func (*Supervisor) EnableChild ¶
func (s *Supervisor) EnableChild(name gen.Atom) error
EnableChild enables the child process in the supervisor spec and attempts to start it. Returns error if spawning child process is failed.
func (*Supervisor) HandleCall ¶
func (*Supervisor) HandleChildStart ¶
func (*Supervisor) HandleChildTerminate ¶
func (*Supervisor) HandleEvent ¶
func (s *Supervisor) HandleEvent(message gen.MessageEvent) error
func (*Supervisor) HandleInspect ¶
func (*Supervisor) HandleMessage ¶
func (s *Supervisor) HandleMessage(from gen.PID, message any) error
func (*Supervisor) ProcessInit ¶
func (s *Supervisor) ProcessInit(process gen.Process, args ...any) (rr error)
ProcessInit
func (*Supervisor) ProcessRun ¶
func (s *Supervisor) ProcessRun() (rr error)
func (*Supervisor) ProcessTerminate ¶
func (s *Supervisor) ProcessTerminate(reason error)
func (*Supervisor) StartChild ¶
func (s *Supervisor) StartChild(name gen.Atom, args ...any) error
StartChild starts new child process defined in the supervisor spec.
func (*Supervisor) Terminate ¶
func (s *Supervisor) Terminate(reason error)
type SupervisorBehavior ¶
type SupervisorBehavior interface { gen.ProcessBehavior // Init invoked on a spawn Supervisor process. This is a mandatory callback for the implementation Init(args ...any) (SupervisorSpec, error) // HandleChildStart invoked on a successful child process starting if option EnableHandleChild // was enabled in act.SupervisorSpec HandleChildStart(name gen.Atom, pid gen.PID) error // HandleChildTerminate invoked on a child process termination if option EnableHandleChild // was enabled in act.SupervisorSpec HandleChildTerminate(name gen.Atom, pid gen.PID, reason error) error // HandleMessage invoked if Supervisor received a message sent with gen.Process.Send(...). // Non-nil value of the returning error will cause termination of this process. // To stop this process normally, return gen.TerminateReasonNormal or // gen.TerminateReasonShutdown. Any other - for abnormal termination. HandleMessage(from gen.PID, message any) error // HandleCall invoked if Supervisor got a synchronous request made with gen.Process.Call(...). // Return nil as a result to handle this request asynchronously and // to provide the result later using the gen.Process.SendResponse(...) method. HandleCall(from gen.PID, ref gen.Ref, request any) (any, error) // Terminate invoked on a termination supervisor process Terminate(reason error) // HandleEvent invoked on an event message if this process got subscribed on // this event using gen.Process.LinkEvent or gen.Process.MonitorEvent HandleEvent(message gen.MessageEvent) error // HandleInspect invoked on the request made with gen.Process.Inspect(...) HandleInspect(from gen.PID, item ...string) map[string]string }
type SupervisorChild ¶
type SupervisorChildSpec ¶
type SupervisorChildSpec struct { Name gen.Atom Significant bool // ignored for SupervisorTypeSimpleOneForOne or if used restart strategy SupervisorStrategyPermanent Factory gen.ProcessFactory Options gen.ProcessOptions Args []any }
SupervisorChildSpec
type SupervisorRestart ¶
type SupervisorRestart struct { Strategy SupervisorStrategy Intensity uint16 Period uint16 KeepOrder bool // ignored for SupervisorTypeSimpleOneForOne and SupervisorTypeOneForOne }
type SupervisorSpec ¶
type SupervisorSpec struct { Children []SupervisorChildSpec Type SupervisorType Restart SupervisorRestart // EnableHandleChild enables HandleChildStart/HandleChildTerminate callback // invoking on starting/stopping child processes. These callbacks are invoked // after the restart strategy finishes its work with all children. EnableHandleChild bool // DisableAutoShutdown makes the supervisor not shutdown if there is no one // running child process left (it happens if all child processes have been // terminated normally - by itself or the child spec was disabled). // This options is ignored for SupervisorTypeSimpleOneForOne // or if used restart strategy SupervisorStrategyPermanent DisableAutoShutdown bool }
SupervisorSpec
type SupervisorStrategy ¶
type SupervisorStrategy int
SupervisorStrategy defines restart strategy for the children processes
const ( // SupervisorStrategyTransient child process is restarted only if // it terminates abnormally, that is, with an exit reason other // than TerminateReasonNormal, TerminateReasonShutdown. // This is default strategy. SupervisorStrategyTransient SupervisorStrategy = 0 // SupervisorStrategyTemporary child process is never restarted // (not even when the supervisor restart strategy is rest_for_one // or one_for_all and a sibling death causes the temporary process // to be terminated) SupervisorStrategyTemporary SupervisorStrategy = 1 // SupervisorStrategyPermanent child process is always restarted SupervisorStrategyPermanent SupervisorStrategy = 2 )
func (SupervisorStrategy) String ¶
func (s SupervisorStrategy) String() string
type SupervisorType ¶
type SupervisorType int
SupervisorType
const ( // SupervisorTypeOneForOne If one child process terminates and is to be restarted, only // that child process is affected. This is the default restart strategy. SupervisorTypeOneForOne SupervisorType = 0 // SupervisorTypeAllForOne If one child process terminates and is to be restarted, all other // child processes are terminated and then all child processes are restarted. SupervisorTypeAllForOne SupervisorType = 1 // SupervisorTypeRestForOne If one child process terminates and is to be restarted, // the 'rest' of the child processes (that is, the child // processes after the terminated child process in the start order) // are terminated. Then the terminated child process and all // child processes after it are restarted SupervisorTypeRestForOne SupervisorType = 2 // SupervisorTypeSimpleOneForOne A simplified one_for_one supervisor, where all // child processes are dynamically added instances // of the same process type, that is, running the same code. SupervisorTypeSimpleOneForOne SupervisorType = 3 )
func (SupervisorType) String ¶
func (s SupervisorType) String() string
type WebWorker ¶
func (*WebWorker) HandleCall ¶
func (*WebWorker) HandleDelete ¶
func (*WebWorker) HandleEvent ¶
func (w *WebWorker) HandleEvent(message gen.MessageEvent) error
func (*WebWorker) HandleHead ¶
func (*WebWorker) HandleInspect ¶
func (*WebWorker) HandleMessage ¶
func (*WebWorker) HandleOptions ¶
func (*WebWorker) HandlePatch ¶
func (*WebWorker) HandlePost ¶
func (*WebWorker) ProcessInit ¶
func (*WebWorker) ProcessRun ¶
func (*WebWorker) ProcessTerminate ¶
type WebWorkerBehavior ¶
type WebWorkerBehavior interface { gen.ProcessBehavior // Init invoked on a spawn WebWorker for the initializing. Init(args ...any) error // HandleMessage invoked if WebWorker received a message sent with gen.Process.Send(...). // Non-nil value of the returning error will cause termination of this process. // To stop this process normally, return gen.TerminateReasonNormal // or any other for abnormal termination. HandleMessage(from gen.PID, message any) error // HandleCall invoked if WebWorker got a synchronous request made with gen.Process.Call(...). // Return nil as a result to handle this request asynchronously and // to provide the result later using the gen.Process.SendResponse(...) method. HandleCall(from gen.PID, ref gen.Ref, request any) (any, error) // Terminate invoked on a termination process Terminate(reason error) // HandleEvent invoked on an event message if this process got subscribed on // this event using gen.Process.LinkEvent or gen.Process.MonitorEvent HandleEvent(message gen.MessageEvent) error // HandleInspect invoked on the request made with gen.Process.Inspect(...) HandleInspect(from gen.PID, item ...string) map[string]string // HandleGet invoked on a GET request HandleGet(from gen.PID, writer http.ResponseWriter, request *http.Request) error // HandlePOST invoked on a POST request HandlePost(from gen.PID, writer http.ResponseWriter, request *http.Request) error // HandlePut invoked on a PUT request HandlePut(from gen.PID, writer http.ResponseWriter, request *http.Request) error // HandlePatch invoked on a PATCH request HandlePatch(from gen.PID, writer http.ResponseWriter, request *http.Request) error // HandleDelete invoked on a DELETE request HandleDelete(from gen.PID, writer http.ResponseWriter, request *http.Request) error // HandleHead invoked on a HEAD request HandleHead(from gen.PID, writer http.ResponseWriter, request *http.Request) error // HandleOptions invoked on an OPTIONS request HandleOptions(from gen.PID, writer http.ResponseWriter, request *http.Request) error }