Documentation
¶
Index ¶
- Constants
- 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) HandleSpan(message gen.TracingSpan) error
- func (a *Actor) Init(args ...any) error
- func (a *Actor) ProcessInit(process gen.Process, args ...any) (rr error)
- func (a *Actor) ProcessKind() gen.ProcessKind
- 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 MessageRouteFailed
- type OnExceed
- 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) ProcessKind() gen.ProcessKind
- 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 Route
- type RoutePending
- type Router
- func (r *Router) AddRoute(route Route) error
- func (r *Router) DisableRoute(name gen.Atom) error
- func (r *Router) EnableRoute(name gen.Atom) error
- func (r *Router) HandleCall(from gen.PID, ref gen.Ref, request any) (any, error)
- func (r *Router) HandleEvent(message gen.MessageEvent) error
- func (r *Router) HandleInspect(from gen.PID, item ...string) map[string]string
- func (r *Router) HandleMessage(from gen.PID, message any) error
- func (r *Router) ProcessInit(process gen.Process, args ...any) (rr error)
- func (r *Router) ProcessKind() gen.ProcessKind
- func (r *Router) ProcessRun() (rr error)
- func (r *Router) ProcessTerminate(reason error)
- func (r *Router) RemoveRoute(name gen.Atom) error
- func (r *Router) ReplaceRoute(name gen.Atom, route Route) error
- func (r *Router) RespawnRoute(name gen.Atom) error
- func (r *Router) Route(name gen.Atom) (RouterRouteInfo, bool)
- func (r *Router) Routes() []RouterRouteInfo
- func (r *Router) Terminate(reason error)
- type RouterBehavior
- type RouterOptions
- type RouterRouteInfo
- 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) ProcessKind() gen.ProcessKind
- 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 SupervisorChildRestart
- 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) ProcessKind() gen.ProcessKind
- func (w *WebWorker) ProcessRun() (rr error)
- func (w *WebWorker) ProcessTerminate(reason error)
- func (w *WebWorker) Terminate(reason error)
- type WebWorkerBehavior
Constants ¶
const RouteDiscard gen.Atom = ""
RouteDiscard is the sentinel returned from RouteMessage and RouteCall to drop the incoming message. Equal to the empty gen.Atom.
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") ErrSupervisorChildDuplicate = errors.New("duplicate child spec Name") ErrSupervisorInvalidSpec = errors.New("invalid supervisor spec") ErrPoolEmpty = errors.New("no worker process in the pool") ErrRouteRunning = errors.New("route is already running") ErrRouteDuplicate = errors.New("duplicate route name") )
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) HandleSpan ¶ added in v1.999.330
func (a *Actor) HandleSpan(message gen.TracingSpan) error
func (*Actor) ProcessInit ¶
ProcessInit
func (*Actor) ProcessKind ¶ added in v1.999.330
func (a *Actor) ProcessKind() gen.ProcessKind
ProcessKind reports this process as built on act.Actor.
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 a request from the parent process, which always terminates the actor regardless of reason. 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
// HandleSpan invoked on a tracing span if this process was added as a tracing exporter.
HandleSpan(message gen.TracingSpan) error
// HandleInspect invoked on the request made with gen.Process.Inspect(...)
HandleInspect(from gen.PID, item ...string) map[string]string
}
ActorBehavior interface
type MessageRouteFailed ¶ added in v1.999.330
MessageRouteFailed is delivered to HandleMessage when a routed async message could not be forwarded. Reason carries the cause:
- gen.ErrProcessUnknown: name resolved to nothing (no route, no registry entry, or respawn of an owned route failed).
- gen.ErrProcessMailboxFull: target's mailbox is full.
- gen.ErrDisabled: target route is disabled or mid-disable.
- gen.ErrNoRoute: target route is being removed.
- gen.ErrBusy: target route is mid-replace with no current worker.
type OnExceed ¶ added in v1.999.330
type OnExceed uint8
OnExceed defines what happens when the per-spec restart intensity is exceeded. Only meaningful when SupervisorChildRestart.Intensity > 0.
const ( // OnExceedTerminateSupervisor terminates the supervisor when the per-spec // restart intensity is exceeded. This is the default. OnExceedTerminateSupervisor OnExceed = 0 // OnExceedDisable disables the offending child when its per-spec or // per-instance restart intensity is exceeded; the supervisor remains // alive. For OneForOne the spec is marked disabled (re-enable via // EnableChild). For SimpleOneForOne the offending instance is dropped // while the spec stays available for new StartChild calls. OnExceedDisable OnExceed = 1 )
type Pool ¶
func (*Pool) HandleCall ¶
func (*Pool) HandleEvent ¶
func (p *Pool) HandleEvent(message gen.MessageEvent) error
func (*Pool) HandleInspect ¶
func (*Pool) ProcessKind ¶ added in v1.999.330
func (p *Pool) ProcessKind() gen.ProcessKind
ProcessKind reports this process as built on act.Pool.
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(...).
// The returning fields are merged into the pool stats, so implement it to
// add the fields of your own. The pool stats use the reserved "ergo:"
// prefix for its keys; a returning field with such a key overrides it.
HandleInspect(from gen.PID, item ...string) map[string]string
}
type PoolOptions ¶
type PoolOptions struct {
WorkerMailboxSize int64
PoolSize int64
WorkerFactory gen.ProcessFactory
WorkerArgs []any
}
type Route ¶ added in v1.999.330
type Route struct {
Name gen.Atom
Factory gen.ProcessFactory
Args []any
}
Route is a named routing destination configured at Router initialization.
type RoutePending ¶ added in v1.999.330
type RoutePending int
RoutePending names the async operation in flight on a route. When non-None, all public route-management methods return gen.ErrBusy.
const ( RoutePendingNone RoutePending = 0 RoutePendingDisable RoutePending = 1 RoutePendingReplace RoutePending = 2 RoutePendingRemove RoutePending = 3 )
func (RoutePending) String ¶ added in v1.999.330
func (p RoutePending) String() string
type Router ¶ added in v1.999.330
Router is the base type embedded in user RouterBehavior implementations.
func (*Router) AddRoute ¶ added in v1.999.330
AddRoute appends a new named route and spawns its worker.
func (*Router) DisableRoute ¶ added in v1.999.330
DisableRoute terminates the route's worker (if running) and marks the route as admin-disabled. Idempotent for already-disabled routes.
func (*Router) EnableRoute ¶ added in v1.999.330
EnableRoute clears the admin-disabled flag and spawns a fresh worker. Idempotent for already-enabled routes.
func (*Router) HandleCall ¶ added in v1.999.330
func (*Router) HandleEvent ¶ added in v1.999.330
func (r *Router) HandleEvent(message gen.MessageEvent) error
func (*Router) HandleInspect ¶ added in v1.999.330
func (*Router) HandleMessage ¶ added in v1.999.330
func (*Router) ProcessInit ¶ added in v1.999.330
func (*Router) ProcessKind ¶ added in v1.999.330
func (r *Router) ProcessKind() gen.ProcessKind
ProcessKind reports this process as built on act.Router.
func (*Router) ProcessRun ¶ added in v1.999.330
func (*Router) ProcessTerminate ¶ added in v1.999.330
func (*Router) RemoveRoute ¶ added in v1.999.330
RemoveRoute terminates the route's worker (if running) and removes the route from the Router. Idempotent for unknown names.
func (*Router) ReplaceRoute ¶ added in v1.999.330
ReplaceRoute swaps the spec for an existing route and (re)spawns the worker with the new spec. The route Name in the provided spec must match `name` or be empty.
func (*Router) RespawnRoute ¶ added in v1.999.330
RespawnRoute spawns a worker for a route that is currently not running. Returns ErrRouteRunning if the worker is alive, gen.ErrDisabled if the route is admin-disabled, gen.ErrBusy if a pending operation is in flight.
func (*Router) Route ¶ added in v1.999.330
func (r *Router) Route(name gen.Atom) (RouterRouteInfo, bool)
Route returns a snapshot of the named route. ok is false when the name is not a known route.
func (*Router) Routes ¶ added in v1.999.330
func (r *Router) Routes() []RouterRouteInfo
Routes returns snapshots of all routes in initialization order.
type RouterBehavior ¶ added in v1.999.330
type RouterBehavior interface {
gen.ProcessBehavior
// Init is invoked on a Router spawn for initialization.
Init(args ...any) (RouterOptions, error)
// Terminate is invoked on Router termination.
Terminate(reason error)
// RouteMessage decides destination for Send arriving with
// MessagePriorityNormal. Returns the target route Name (or a name of a
// process registered on this node, used as a fallback). Returns
// RouteDiscard to drop the message; discarded counter is incremented and
// the sender receives no notification.
RouteMessage(from gen.PID, message any) gen.Atom
// RouteCall decides destination for Call arriving with
// MessagePriorityNormal. Returns the target route Name. Returns
// RouteDiscard to respond gen.ErrDiscarded to the caller.
RouteCall(from gen.PID, ref gen.Ref, request any) gen.Atom
// HandleMessage is invoked for Send arriving with MessagePriorityHigh or
// Max, and for self-delivered MessageRouteFailed sentinels when a routed
// async message could not be forwarded.
HandleMessage(from gen.PID, message any) error
// HandleCall is invoked for Call arriving with MessagePriorityHigh or
// Max. Return non-nil result to respond synchronously, nil to defer the
// response via SendResponse. Non-nil reason terminates the Router; if
// reason is gen.TerminateReasonNormal and result is non-nil, the result
// is delivered to the caller before the Router shuts down.
HandleCall(from gen.PID, ref gen.Ref, request any) (any, error)
// HandleEvent is invoked on a subscribed event.
HandleEvent(message gen.MessageEvent) error
// HandleInspect is invoked on Inspect requests. The returning fields are
// merged into the routing statistics, so implement it to add the fields of
// your own. The routing statistics use the reserved "ergo:" prefix for its
// keys; a returning field with such a key overrides it.
HandleInspect(from gen.PID, item ...string) map[string]string
}
RouterBehavior is the interface a Router implementation must satisfy.
Routing callbacks (RouteMessage, RouteCall) receive traffic delivered with MessagePriorityNormal and return the target name. Admin callbacks (HandleMessage, HandleCall) receive traffic delivered with MessagePriorityHigh or Max and are not routed.
type RouterOptions ¶ added in v1.999.330
RouterOptions configures a Router process.
type RouterRouteInfo ¶ added in v1.999.330
RouterRouteInfo is a snapshot of a route returned from Routes() and Route(). PID is empty when the route is not currently running.
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. Returns ErrSupervisorChildRunning if the child is still terminating after DisableChild; retry once it has stopped.
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) ProcessKind ¶ added in v1.999.330
func (s *Supervisor) ProcessKind() gen.ProcessKind
ProcessKind reports this process as built on act.Supervisor.
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(...).
// The returning fields are merged into the supervisor state (strategy,
// children), so implement it to add the fields of your own. The supervisor
// state uses the reserved "ergo:" prefix for its keys; a returning field
// with such a key overrides it.
HandleInspect(from gen.PID, item ...string) map[string]string
}
type SupervisorChild ¶
type SupervisorChildRestart ¶ added in v1.999.330
type SupervisorChildRestart struct {
Strategy SupervisorStrategy
Intensity uint16
Period uint16
OnExceed OnExceed
}
SupervisorChildRestart is an optional per-child override of the supervisor-level restart configuration. Zero-value fields inherit: Strategy == SupervisorStrategyInherit uses the supervisor Strategy; Intensity == 0 uses the supervisor's global counter (Period is then ignored). Setting Intensity > 0 enables a dedicated per-spec counter (per-instance for SimpleOneForOne). OnExceed == OnExceedDisable requires Intensity > 0 and is rejected for SupervisorTypeAllForOne and SupervisorTypeRestForOne.
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
Restart SupervisorChildRestart
}
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 ( // SupervisorStrategyInherit is a sentinel valid only inside SupervisorChildRestart. // At child level it means the child uses the supervisor-level Strategy. // At supervisor level it is normalized to SupervisorStrategyTransient on init. SupervisorStrategyInherit SupervisorStrategy = 0 // 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 = 1 // 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 = 2 // SupervisorStrategyPermanent child process is always restarted SupervisorStrategyPermanent SupervisorStrategy = 3 )
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) ProcessKind ¶ added in v1.999.330
func (w *WebWorker) ProcessKind() gen.ProcessKind
ProcessKind reports this process as built on act.WebWorker.
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
}