act

package
v1.999.330 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: MIT Imports: 9 Imported by: 30

Documentation

Index

Constants

View Source
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

View Source
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

type Actor struct {
	gen.Process
	// contains filtered or unexported fields
}

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 (a *Actor) HandleCall(from gen.PID, ref gen.Ref, request any) (any, error)

func (*Actor) HandleCallAlias

func (a *Actor) HandleCallAlias(alias gen.Alias, from gen.PID, ref gen.Ref, request any) (any, error)

func (*Actor) HandleCallName

func (a *Actor) HandleCallName(name gen.Atom, from gen.PID, ref gen.Ref, request any) (any, error)

func (*Actor) HandleEvent

func (a *Actor) HandleEvent(message gen.MessageEvent) error

func (*Actor) HandleInspect

func (a *Actor) HandleInspect(from gen.PID, item ...string) map[string]string

func (*Actor) HandleLog

func (a *Actor) HandleLog(message gen.MessageLog) error

func (*Actor) HandleMessage

func (a *Actor) HandleMessage(from gen.PID, message any) error

func (*Actor) HandleMessageAlias

func (a *Actor) HandleMessageAlias(alias gen.Alias, from gen.PID, message any) error

func (*Actor) HandleMessageName

func (a *Actor) HandleMessageName(name gen.Atom, from gen.PID, message any) error

func (*Actor) HandleSpan added in v1.999.330

func (a *Actor) HandleSpan(message gen.TracingSpan) error

func (*Actor) Init

func (a *Actor) Init(args ...any) error

Init

func (*Actor) ProcessInit

func (a *Actor) ProcessInit(process gen.Process, args ...any) (rr error)

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 (a *Actor) ProcessRun() (rr error)

func (*Actor) ProcessTerminate

func (a *Actor) ProcessTerminate(reason error)

func (*Actor) SetSplitHandle

func (a *Actor) SetSplitHandle(split bool)

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

func (a *Actor) SetTrapExit(trap bool)

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

func (a *Actor) SplitHandle() bool

SplitHandle returns whether the splitting was enabled on this actor

func (*Actor) Terminate

func (a *Actor) Terminate(reason error)

func (*Actor) TrapExit

func (a *Actor) TrapExit() bool

TrapExit returns whether the trap 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

type MessageRouteFailed struct {
	Name    gen.Atom
	From    gen.PID
	Message any
	Reason  error
}

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
)

func (OnExceed) String added in v1.999.330

func (a OnExceed) String() string

type Pool

type Pool struct {
	gen.Process
	// contains filtered or unexported fields
}

func (*Pool) AddWorkers

func (p *Pool) AddWorkers(n int) (int64, error)

func (*Pool) HandleCall

func (p *Pool) HandleCall(from gen.PID, ref gen.Ref, request any) (any, error)

func (*Pool) HandleEvent

func (p *Pool) HandleEvent(message gen.MessageEvent) error

func (*Pool) HandleInspect

func (p *Pool) HandleInspect(from gen.PID, item ...string) map[string]string

func (*Pool) HandleMessage

func (p *Pool) HandleMessage(from gen.PID, message any) error

func (*Pool) ProcessInit

func (p *Pool) ProcessInit(process gen.Process, args ...any) (rr error)

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 (p *Pool) ProcessRun() (rr error)

func (*Pool) ProcessTerminate

func (p *Pool) ProcessTerminate(reason error)

func (*Pool) RemoveWorkers

func (p *Pool) RemoveWorkers(n int) (int64, error)

func (*Pool) Terminate

func (p *Pool) Terminate(reason error)

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

type Router struct {
	gen.Process
	// contains filtered or unexported fields
}

Router is the base type embedded in user RouterBehavior implementations.

func (*Router) AddRoute added in v1.999.330

func (r *Router) AddRoute(route Route) error

AddRoute appends a new named route and spawns its worker.

func (*Router) DisableRoute added in v1.999.330

func (r *Router) DisableRoute(name gen.Atom) error

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

func (r *Router) EnableRoute(name gen.Atom) error

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 (r *Router) HandleCall(from gen.PID, ref gen.Ref, request any) (any, error)

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 (r *Router) HandleInspect(from gen.PID, item ...string) map[string]string

func (*Router) HandleMessage added in v1.999.330

func (r *Router) HandleMessage(from gen.PID, message any) error

func (*Router) ProcessInit added in v1.999.330

func (r *Router) ProcessInit(process gen.Process, args ...any) (rr error)

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 (r *Router) ProcessRun() (rr error)

func (*Router) ProcessTerminate added in v1.999.330

func (r *Router) ProcessTerminate(reason error)

func (*Router) RemoveRoute added in v1.999.330

func (r *Router) RemoveRoute(name gen.Atom) error

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

func (r *Router) ReplaceRoute(name gen.Atom, route Route) error

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

func (r *Router) RespawnRoute(name gen.Atom) error

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.

func (*Router) Terminate added in v1.999.330

func (r *Router) Terminate(reason error)

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

type RouterOptions struct {
	Routes      []Route
	MailboxSize int64
}

RouterOptions configures a Router process.

type RouterRouteInfo added in v1.999.330

type RouterRouteInfo struct {
	Name     gen.Atom
	PID      gen.PID
	Disabled bool
	Pending  RoutePending
}

RouterRouteInfo is a snapshot of a route returned from Routes() and Route(). PID is empty when the route is not currently running.

type Supervisor

type Supervisor struct {
	gen.Process
	// contains filtered or unexported fields
}

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 (s *Supervisor) HandleCall(from gen.PID, ref gen.Ref, request any) (any, error)

func (*Supervisor) HandleChildStart

func (s *Supervisor) HandleChildStart(name gen.Atom, pid gen.PID) error

func (*Supervisor) HandleChildTerminate

func (s *Supervisor) HandleChildTerminate(name gen.Atom, pid gen.PID, reason error) error

func (*Supervisor) HandleEvent

func (s *Supervisor) HandleEvent(message gen.MessageEvent) error

func (*Supervisor) HandleInspect

func (s *Supervisor) HandleInspect(from gen.PID, item ...string) map[string]string

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 SupervisorChild struct {
	Spec        gen.Atom
	Name        gen.Atom
	PID         gen.PID
	Significant bool
	Disabled    bool
}

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

type WebWorker struct {
	gen.Process
	// contains filtered or unexported fields
}

func (*WebWorker) HandleCall

func (w *WebWorker) HandleCall(from gen.PID, ref gen.Ref, request any) (any, error)

func (*WebWorker) HandleDelete

func (w *WebWorker) HandleDelete(from gen.PID, writer http.ResponseWriter, request *http.Request) error

func (*WebWorker) HandleEvent

func (w *WebWorker) HandleEvent(message gen.MessageEvent) error

func (*WebWorker) HandleGet

func (w *WebWorker) HandleGet(from gen.PID, writer http.ResponseWriter, request *http.Request) error

func (*WebWorker) HandleHead

func (w *WebWorker) HandleHead(from gen.PID, writer http.ResponseWriter, request *http.Request) error

func (*WebWorker) HandleInspect

func (w *WebWorker) HandleInspect(from gen.PID, item ...string) map[string]string

func (*WebWorker) HandleMessage

func (w *WebWorker) HandleMessage(from gen.PID, message any) error

func (*WebWorker) HandleOptions

func (w *WebWorker) HandleOptions(from gen.PID, writer http.ResponseWriter, request *http.Request) error

func (*WebWorker) HandlePatch

func (w *WebWorker) HandlePatch(from gen.PID, writer http.ResponseWriter, request *http.Request) error

func (*WebWorker) HandlePost

func (w *WebWorker) HandlePost(from gen.PID, writer http.ResponseWriter, request *http.Request) error

func (*WebWorker) HandlePut

func (w *WebWorker) HandlePut(from gen.PID, writer http.ResponseWriter, request *http.Request) error

func (*WebWorker) Init

func (w *WebWorker) Init(args ...any) error

default callbacks for WebWorkerBehavior interface

func (*WebWorker) ProcessInit

func (w *WebWorker) ProcessInit(process gen.Process, args ...any) (rr error)

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 (w *WebWorker) ProcessRun() (rr error)

func (*WebWorker) ProcessTerminate

func (w *WebWorker) ProcessTerminate(reason error)

func (*WebWorker) Terminate

func (w *WebWorker) Terminate(reason error)

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
}

Jump to

Keyboard shortcuts

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