Documentation ¶
Index ¶
- Constants
- Variables
- type Application
- type ApplicationBehaviour
- type ApplicationChildSpec
- type ApplicationInfo
- type ApplicationSpec
- type ApplicationStartType
- type GenServer
- type GenServerBehaviour
- type GenStage
- func (gst *GenStage) Ask(p *Process, subscription GenStageSubscription, count uint) error
- func (gst *GenStage) Cancel(p *Process, subscription GenStageSubscription, reason string) error
- func (gst *GenStage) DisableAutoDemand(p *Process, subscription GenStageSubscription) error
- func (gst *GenStage) DisableForwardDemand(p *Process) error
- func (gst *GenStage) EnableAutoDemand(p *Process, subscription GenStageSubscription) error
- func (gst *GenStage) EnableForwardDemand(p *Process) error
- func (gst *GenStage) HandleCall(from etf.Tuple, message etf.Term, state interface{}) (string, etf.Term, interface{})
- func (gst *GenStage) HandleCancel(subscription GenStageSubscription, reason string, state interface{}) error
- func (gst *GenStage) HandleCanceled(subscription GenStageSubscription, reason string, state interface{}) error
- func (gst *GenStage) HandleCast(message etf.Term, state interface{}) (string, interface{})
- func (gst *GenStage) HandleDemand(subscription GenStageSubscription, count uint, state interface{}) (error, etf.List)
- func (gst *GenStage) HandleEvents(subscription GenStageSubscription, events etf.List, state interface{}) error
- func (gst *GenStage) HandleGenStageCall(from etf.Tuple, message etf.Term, state interface{}) (string, etf.Term)
- func (gst *GenStage) HandleGenStageCast(message etf.Term, state interface{}) string
- func (gst *GenStage) HandleGenStageInfo(message etf.Term, state interface{}) string
- func (gst *GenStage) HandleInfo(message etf.Term, state interface{}) (string, interface{})
- func (gst *GenStage) HandleSubscribe(subscription GenStageSubscription, options GenStageSubscribeOptions, ...) error
- func (gst *GenStage) HandleSubscribed(subscription GenStageSubscription, opts GenStageSubscribeOptions, ...) (error, bool)
- func (gst *GenStage) Init(p *Process, args ...interface{}) interface{}
- func (gst *GenStage) InitStage(process *Process, args ...interface{}) (GenStageOptions, interface{})
- func (gst *GenStage) SendEvents(p *Process, events etf.List) error
- func (gst *GenStage) SetCancelMode(p *Process, subscription GenStageSubscription, cancel GenStageCancelMode) error
- func (gst *GenStage) Subscribe(p *Process, producer etf.Term, opts GenStageSubscribeOptions) GenStageSubscription
- func (gst *GenStage) Terminate(reason string, state interface{})
- type GenStageBehaviour
- type GenStageCancelMode
- type GenStageCancelReason
- type GenStageDispatchItem
- type GenStageDispatcher
- type GenStageDispatcherBehaviour
- type GenStageOptions
- type GenStageSubscribeOptions
- type GenStageSubscribeTo
- type GenStageSubscription
- type Node
- func (n *Node) AddStaticRoute(name string, port uint16) error
- func (n *Node) ApplicationLoad(app interface{}, args ...interface{}) error
- func (n *Node) ApplicationStart(appName string, args ...interface{}) (*Process, error)
- func (n *Node) ApplicationStartPermanent(appName string, args ...interface{}) (*Process, error)
- func (n *Node) ApplicationStartTransient(appName string, args ...interface{}) (*Process, error)
- func (n *Node) ApplicationStop(name string) error
- func (n *Node) ApplicationUnload(appName string) error
- func (n *Node) GetApplicationInfo(name string) (ApplicationInfo, error)
- func (n *Node) GetPeerList() []string
- func (n *Node) GetProcessByName(name string) *Process
- func (n *Node) GetProcessByPid(pid etf.Pid) *Process
- func (n *Node) GetProcessList() []*Process
- func (n *Node) IsAlive() bool
- func (n *Node) IsProcessAlive(pid etf.Pid) bool
- func (n *Node) LoadedApplications() []ApplicationInfo
- func (n *Node) MakeRef() (ref etf.Ref)
- func (n *Node) ProcessInfo(pid etf.Pid) (ProcessInfo, error)
- func (n *Node) ProvideRPC(module string, function string, fun rpcFunction) error
- func (n *Node) Register(name string, pid etf.Pid) error
- func (n *Node) RemoveStaticRoute(name string)
- func (n *Node) ResolvePort(name string) int
- func (n *Node) RevokeRPC(module, function string) error
- func (n *Node) Spawn(name string, opts ProcessOptions, object interface{}, args ...interface{}) (*Process, error)
- func (n *Node) Unregister(name string)
- func (n *Node) VersionERTS() string
- func (n *Node) VersionOTP() int
- func (n *Node) Wait()
- func (n *Node) WaitWithTimeout(d time.Duration) error
- func (n *Node) WhichApplications() []ApplicationInfo
- type NodeOptions
- type Process
- func (p *Process) Call(to interface{}, message etf.Term) (etf.Term, error)
- func (p *Process) CallRPC(node, module, function string, args ...etf.Term) (etf.Term, error)
- func (p *Process) CallRPCWithTimeout(timeout int, node, module, function string, args ...etf.Term) (etf.Term, error)
- func (p *Process) CallWithTimeout(to interface{}, message etf.Term, timeout int) (etf.Term, error)
- func (p *Process) Cast(to interface{}, message etf.Term)
- func (p *Process) CastAfter(to interface{}, message etf.Term, after time.Duration) context.CancelFunc
- func (p *Process) CastRPC(node, module, function string, args ...etf.Term)
- func (p *Process) DemonitorNode(ref etf.Ref)
- func (p *Process) DemonitorProcess(ref etf.Ref) bool
- func (p *Process) GetChildren() []etf.Pid
- func (p *Process) GetEnv(name string) interface{}
- func (p *Process) GetState() string
- func (p *Process) GetTrapExit() bool
- func (p *Process) Info() ProcessInfo
- func (p *Process) IsAlive() bool
- func (p *Process) Link(with etf.Pid)
- func (p *Process) ListEnv() map[string]interface{}
- func (p *Process) MonitorNode(name string) etf.Ref
- func (p *Process) MonitorProcess(process interface{}) etf.Ref
- func (p *Process) Name() string
- func (p *Process) Self() etf.Pid
- func (p *Process) Send(to interface{}, message etf.Term)
- func (p *Process) SendAfter(to interface{}, message etf.Term, after time.Duration) context.CancelFunc
- func (p *Process) SetEnv(name string, value interface{})
- func (p *Process) SetTrapExit(trap bool)
- func (p *Process) Unlink(with etf.Pid)
- func (p *Process) Wait()
- func (p *Process) WaitWithTimeout(d time.Duration) error
- type ProcessBehaviour
- type ProcessExitFunc
- type ProcessInfo
- type ProcessOptions
- type ProcessType
- type Supervisor
- type SupervisorBehaviour
- type SupervisorChild
- type SupervisorChildRestart
- type SupervisorChildShutdown
- type SupervisorChildSpec
- type SupervisorSpec
- type SupervisorStrategy
- type SupervisorStrategyType
- type TLSmodeType
Constants ¶
const ( // ApplicationStartPermanent If a permanent application terminates, // all other applications and the runtime system (node) are also terminated. ApplicationStartPermanent = "permanent" // ApplicationStartTemporary If a temporary application terminates, // this is reported but no other applications are terminated. ApplicationStartTemporary = "temporary" // ApplicationStartTransient If a transient application terminates // with reason normal, this is reported but no other applications are // terminated. If a transient application terminates abnormally, that // is with any other reason than normal, all other applications and // the runtime system (node) are also terminated. ApplicationStartTransient = "transient" )
const ( // SupervisorRestartIntensity SupervisorRestartIntensity = uint16(10) // SupervisorRestartPeriod SupervisorRestartPeriod = uint16(10) // SupervisorStrategyOneForOne If one child process terminates and is to be restarted, only // that child process is affected. This is the default restart strategy. SupervisorStrategyOneForOne = SupervisorStrategyType("one_for_one") // SupervisorStrategyOneForAll If one child process terminates and is to be restarted, all other // child processes are terminated and then all child processes are restarted. SupervisorStrategyOneForAll = SupervisorStrategyType("one_for_all") // SupervisorStrategyRestForOne 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 SupervisorStrategyRestForOne = SupervisorStrategyType("rest_for_one") // SupervisorStrategySimpleOneForOne 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. SupervisorStrategySimpleOneForOne = SupervisorStrategyType("simple_one_for_one") // SupervisorChildRestartPermanent child process is always restarted SupervisorChildRestartPermanent = SupervisorChildRestart("permanent") // SupervisorChildRestartTemporary 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) SupervisorChildRestartTemporary = SupervisorChildRestart("temporary") // SupervisorChildRestartTransient child process is restarted only if // it terminates abnormally, that is, with an exit reason other // than normal, shutdown, or {shutdown,Term}. SupervisorChildRestartTransient = SupervisorChildRestart("transient") // SupervisorChildShutdownBrutal means that the child process is // unconditionally terminated using process' Kill method SupervisorChildShutdownBrutal = -1 // SupervisorChildShutdownInfinity means that the supervisor will // wait for an exit signal as long as child takes SupervisorChildShutdownInfinity = 0 // default shutdown behaviour // SupervisorChildShutdownTimeout5sec predefined timeout value SupervisorChildShutdownTimeout5sec = 5 )
const (
DefaultCallTimeout = 5
)
const (
DefaultProcessMailboxSize = 100
)
Variables ¶
var ( ErrAppAlreadyLoaded = fmt.Errorf("Application is already loaded") ErrAppAlreadyStarted = fmt.Errorf("Application is already started") ErrAppUnknown = fmt.Errorf("Unknown application name") ErrAppIsNotRunning = fmt.Errorf("Application is not running") ErrProcessBusy = fmt.Errorf("Process is busy") ErrNameIsTaken = fmt.Errorf("Name is taken") ErrUnsupportedRequest = fmt.Errorf("Unsupported request") ErrTimeout = fmt.Errorf("Timed out") ErrFragmented = fmt.Errorf("Fragmented data") ErrStop = fmt.Errorf("stop") )
var (
ErrNotAProducer = fmt.Errorf("not a producer")
)
Functions ¶
This section is empty.
Types ¶
type Application ¶
type Application struct{}
Application is implementation of ProcessBehaviour interface
func (*Application) Loop ¶ added in v1.2.0
func (a *Application) Loop(p *Process, args ...interface{}) string
type ApplicationBehaviour ¶ added in v1.2.0
type ApplicationBehaviour interface { Load(args ...interface{}) (ApplicationSpec, error) Start(process *Process, args ...interface{}) }
ApplicationBehaviour interface
type ApplicationChildSpec ¶
type ApplicationChildSpec struct { Child interface{} Name string Args []interface{} // contains filtered or unexported fields }
type ApplicationInfo ¶
type ApplicationSpec ¶
type ApplicationStartType ¶
type ApplicationStartType = string
type GenServer ¶
type GenServer struct{}
GenServer is implementation of ProcessBehaviour interface for GenServer objects
type GenServerBehaviour ¶ added in v1.2.0
type GenServerBehaviour interface { // Init(...) -> state Init(process *Process, args ...interface{}) (state interface{}) // HandleCast -> ("noreply", state) - noreply // ("stop", reason) - stop with reason HandleCast(message etf.Term, state interface{}) (string, interface{}) // HandleCall -> ("reply", message, state) - reply // ("noreply", _, state) - noreply // ("stop", reason, _) - normal stop HandleCall(from etf.Tuple, message etf.Term, state interface{}) (string, etf.Term, interface{}) // HandleInfo -> ("noreply", state) - noreply // ("stop", reason) - normal stop HandleInfo(message etf.Term, state interface{}) (string, interface{}) Terminate(reason string, state interface{}) }
GenServerBehaviour interface
type GenStage ¶ added in v1.2.0
type GenStage struct {
GenServer
}
func (*GenStage) Ask ¶ added in v1.2.0
func (gst *GenStage) Ask(p *Process, subscription GenStageSubscription, count uint) error
Ask makes a demand request for the given subscription. This function must only be used in the cases when a consumer sets a subscription to manual mode using DisableAutoDemand
func (*GenStage) Cancel ¶ added in v1.2.0
func (gst *GenStage) Cancel(p *Process, subscription GenStageSubscription, reason string) error
Cancel
func (*GenStage) DisableAutoDemand ¶ added in v1.2.0
func (gst *GenStage) DisableAutoDemand(p *Process, subscription GenStageSubscription) error
DisableAutoDemand means that demand must be sent to producers explicitly using Ask method. This mode can be used when a special behaviour is desired.
func (*GenStage) DisableForwardDemand ¶ added in v1.2.0
DisableForwardDemand disables forwarding messages to the HandleDemand on a producer stage. This is useful as a synchronization mechanism, where the demand is accumulated until all consumers are subscribed.
func (*GenStage) EnableAutoDemand ¶ added in v1.2.0
func (gst *GenStage) EnableAutoDemand(p *Process, subscription GenStageSubscription) error
EnableAutoDemand enables auto demand mode (this is default mode for the consumer).
func (*GenStage) EnableForwardDemand ¶ added in v1.2.0
EnableForwardDemand enables forwarding messages to the HandleDemand on a producer stage. This is default mode for the producer.
func (*GenStage) HandleCall ¶ added in v1.2.0
func (*GenStage) HandleCancel ¶ added in v1.2.0
func (gst *GenStage) HandleCancel(subscription GenStageSubscription, reason string, state interface{}) error
func (*GenStage) HandleCanceled ¶ added in v1.2.0
func (gst *GenStage) HandleCanceled(subscription GenStageSubscription, reason string, state interface{}) error
func (*GenStage) HandleCast ¶ added in v1.2.0
func (*GenStage) HandleDemand ¶ added in v1.2.0
func (*GenStage) HandleEvents ¶ added in v1.2.0
func (gst *GenStage) HandleEvents(subscription GenStageSubscription, events etf.List, state interface{}) error
func (*GenStage) HandleGenStageCall ¶ added in v1.2.0
func (*GenStage) HandleGenStageCast ¶ added in v1.2.0
func (*GenStage) HandleGenStageInfo ¶ added in v1.2.0
func (*GenStage) HandleInfo ¶ added in v1.2.0
func (*GenStage) HandleSubscribe ¶ added in v1.2.0
func (gst *GenStage) HandleSubscribe(subscription GenStageSubscription, options GenStageSubscribeOptions, state interface{}) error
func (*GenStage) HandleSubscribed ¶ added in v1.2.0
func (gst *GenStage) HandleSubscribed(subscription GenStageSubscription, opts GenStageSubscribeOptions, state interface{}) (error, bool)
func (*GenStage) InitStage ¶ added in v1.2.0
func (gst *GenStage) InitStage(process *Process, args ...interface{}) (GenStageOptions, interface{})
func (*GenStage) SendEvents ¶ added in v1.2.0
SendEvents sends events for the subscribers
func (*GenStage) SetCancelMode ¶ added in v1.2.0
func (gst *GenStage) SetCancelMode(p *Process, subscription GenStageSubscription, cancel GenStageCancelMode) error
SetCancelMode defines how consumer will handle termination of the producer. There are 3 modes: GenStageCancelPermanent (default) - consumer exits when the producer cancels or exits GenStageCancelTransient - consumer exits only if reason is not normal, shutdown, or {shutdown, reason} GenStageCancelTemporary - never exits
func (*GenStage) Subscribe ¶ added in v1.2.0
func (gst *GenStage) Subscribe(p *Process, producer etf.Term, opts GenStageSubscribeOptions) GenStageSubscription
Subscribe subscribes to the given producer. HandleSubscribed callback will be invoked on a consumer stage once a request for the subscription is sent. If something went wrong on a producer side the callback HandleCancel will be invoked with a reason of cancelation.
type GenStageBehaviour ¶ added in v1.2.0
type GenStageBehaviour interface { // InitStage InitStage(process *Process, args ...interface{}) (GenStageOptions, interface{}) // HandleDemand this callback is invoked on a producer stage // The producer that implements this callback must either store the demand, or return the amount of requested events. // Use `ergo.ErrStop` as an error for the normal shutdown this process. Any other error values // will be used as a reason for the abnornal shutdown process. HandleDemand(subscription GenStageSubscription, count uint, state interface{}) (error, etf.List) // HandleEvents this callback is invoked on a consumer stage. // Use `ergo.ErrStop` as an error for the normal shutdown this process. Any other error values // will be used as a reason for the abnornal shutdown process. HandleEvents(subscription GenStageSubscription, events etf.List, state interface{}) error // HandleSubscribe This callback is invoked on a producer stage. // Use `ergo.ErrStop` as an error for the normal shutdown this process. Any other error values // will be used as a reason for the abnornal shutdown process. HandleSubscribe(subscription GenStageSubscription, options GenStageSubscribeOptions, state interface{}) error // HandleSubscribed this callback is invoked as a confirmation for the subscription request // Returning false means that demand must be sent to producers explicitly using Ask method. // Returning true means the stage implementation will take care of automatically sending. // Use `ergo.ErrStop` as an error for the normal shutdown this process. Any other error values HandleSubscribed(subscription GenStageSubscription, opts GenStageSubscribeOptions, state interface{}) (error, bool) // HandleCancel // Invoked when a consumer is no longer subscribed to a producer (invoked on a producer stage) // The cancelReason will be a {Cancel: "cancel", Reason: _} if the reason for cancellation // was a GenStage.Cancel call. Any other value means the cancellation reason was // due to an EXIT. // Use `ergo.ErrStop` as an error for the normal shutdown this process. Any other error values // will be used as a reason for the abnornal shutdown process. HandleCancel(subscription GenStageSubscription, reason string, state interface{}) error // HandleCanceled // Invoked when a consumer is no longer subscribed to a producer (invoked on a consumer stage) // Termination this stage depends on a cancel mode for the given subscription. For the cancel mode // GenStageCancelPermanent - this stage will be terminated right after this callback invoking. // For the cancel mode GenStageCancelTransient - it depends on a reason of subscription canceling. // Cancel mode GenStageCancelTemporary keeps this stage alive whether the reason could be. HandleCanceled(subscription GenStageSubscription, reason string, state interface{}) error // HandleGenStageCall this callback is invoked on Process.Call. This method is optional // for the implementation HandleGenStageCall(from etf.Tuple, message etf.Term, state interface{}) (string, etf.Term) // HandleGenStageCast this callback is invoked on Process.Cast. This method is optional // for the implementation HandleGenStageCast(message etf.Term, state interface{}) string // HandleGenStageInfo this callback is invoked on Process.Send. This method is optional // for the implementation HandleGenStageInfo(message etf.Term, state interface{}) string }
GenStageBehaviour interface for the GenStage inmplementation
type GenStageCancelMode ¶ added in v1.2.0
type GenStageCancelMode uint
const ( GenStageCancelPermanent GenStageCancelMode = 0 GenStageCancelTransient GenStageCancelMode = 1 GenStageCancelTemporary GenStageCancelMode = 2 )
type GenStageCancelReason ¶ added in v1.2.0
type GenStageDispatchItem ¶ added in v1.2.0
type GenStageDispatchItem struct {
// contains filtered or unexported fields
}
type GenStageDispatcher ¶ added in v1.2.0
type GenStageDispatcher int
type GenStageDispatcherBehaviour ¶ added in v1.2.0
type GenStageDispatcherBehaviour interface { // InitStageDispatcher(opts) Init(opts GenStageOptions) interface{} // Ask called every time a consumer sends demand Ask(subscription GenStageSubscription, count uint, state interface{}) // Cancel called every time a subscription is cancelled or the consumer goes down. Cancel(subscription GenStageSubscription, state interface{}) // Dispatch called every time a producer wants to dispatch an event. Dispatch(events etf.List, state interface{}) []GenStageDispatchItem // Subscribe called every time the producer gets a new subscriber Subscribe(subscription GenStageSubscription, opts GenStageSubscribeOptions, state interface{}) error }
GenStageDispatcherBehaviour defined interface for the dispatcher implementation. To create a custom dispatcher you should implement this interface and use it in GenStageOptions as a Dispatcher
func CreateGenStageDispatcherBroadcast ¶ added in v1.2.0
func CreateGenStageDispatcherBroadcast() GenStageDispatcherBehaviour
CreateGenStageDispatcherBroadcast creates a dispatcher that accumulates demand from all consumers before broadcasting events to all of them. This dispatcher guarantees that events are dispatched to all consumers without exceeding the demand of any given consumer. The demand is only sent upstream once all consumers ask for data.
func CreateGenStageDispatcherDemand ¶ added in v1.2.0
func CreateGenStageDispatcherDemand() GenStageDispatcherBehaviour
CreateGenStageDispatcherDemand creates a dispatcher that sends batches to the highest demand. This is the default dispatcher used by GenStage. In order to avoid greedy consumers, it is recommended that all consumers have exactly the same maximum demand.
func CreateGenStageDispatcherPartition ¶ added in v1.2.0
func CreateGenStageDispatcherPartition(n uint, hash func(etf.Term) int) GenStageDispatcherBehaviour
CreateGenStageDispatcherPartition creates a dispatcher that sends events according to partitions. Number of partitions 'n' must be > 0. 'hash' should return number within range [0,n). Value outside of this range is discarding event. If 'hash' is nil the random partition will be used on every event.
type GenStageOptions ¶ added in v1.2.0
type GenStageOptions struct { // If this stage acts as a consumer you can to define producers // this stage should subscribe to. // SubscribeTo is a list of GenStageSubscribeTo. Each element represents // a producer (etf.Pid or registered name) and subscription options. SubscribeTo []GenStageSubscribeTo // DisableForwarding. the demand is always forwarded to the HandleDemand callback. // When this options is set to 'true', demands are accumulated until mode is // set back to 'false' using DisableDemandAccumulating method DisableForwarding bool // BufferSize the size of the buffer to store events without demand. // default value = defaultDispatcherBufferSize BufferSize uint // BufferKeepLast defines whether the first or last entries should be // kept on the buffer in case the buffer size is exceeded. BufferKeepLast bool Dispatcher GenStageDispatcherBehaviour }
GenStageOptions defines the GenStage' configuration using Init callback. Some options are specific to the chosen stage mode while others are shared across all types.
type GenStageSubscribeOptions ¶ added in v1.2.0
type GenStageSubscribeOptions struct { MinDemand uint `etf:"min_demand"` MaxDemand uint `etf:"max_demand"` // The stage implementation will take care of automatically sending // demand to producer (as a default behaviour). You can disable it // setting ManualDemand to true ManualDemand bool `etf:"manual"` // What should happend with consumer if producer has terminated // GenStageCancelPermanent the consumer exits when the producer cancels or exits. // GenStageCancelTransient the consumer exits only if reason is not "normal", // "shutdown", or {"shutdown", _} // GenStageCancelTemporary the consumer never exits Cancel GenStageCancelMode `etf:"cancel"` // Partition is defined the number of partition this subscription should belongs to. // This option uses in the DispatcherPartition Partition uint `etf:"partition"` // Extra is intended to be a custom set of options for the custom implementation // of GenStageDispatcherBehaviour Extra etf.Term `etf:"extra"` }
type GenStageSubscribeTo ¶ added in v1.2.0
type GenStageSubscribeTo struct { Producer etf.Term Options GenStageSubscribeOptions }
type GenStageSubscription ¶ added in v1.2.0
type Node ¶
type Node struct { Cookie string Stop context.CancelFunc StartedAt time.Time FullName string // contains filtered or unexported fields }
Node instance of created node using CreateNode
func CreateNode ¶
func CreateNode(name string, cookie string, opts NodeOptions) *Node
CreateNode create new node with name and cookie string
func CreateNodeWithContext ¶
CreateNodeWithContext create new node with specified context, name and cookie string
func (*Node) AddStaticRoute ¶ added in v1.2.0
AddStaticRoute adds static route record into the EPMD client
func (*Node) ApplicationLoad ¶
ApplicationLoad loads the application specification for an application into the node. It also loads the application specifications for any included applications
func (*Node) ApplicationStart ¶
ApplicationStart start Application with start type ApplicationStartTemporary If an application terminates, this is reported but no other applications are terminated
func (*Node) ApplicationStartPermanent ¶
ApplicationStartPermanent start Application with start type ApplicationStartPermanent If this application terminates, all other applications and the entire node are also terminated
func (*Node) ApplicationStartTransient ¶
ApplicationStartTransient start Application with start type ApplicationStartTransient If transient application terminates with reason 'normal', this is reported and no other applications are terminated. Otherwise, all other applications and node are terminated
func (*Node) ApplicationStop ¶
ApplicationStop stop running application
func (*Node) ApplicationUnload ¶
ApplicationUnload unloads the application specification for Application from the node. It also unloads the application specifications for any included applications.
func (*Node) GetApplicationInfo ¶
func (n *Node) GetApplicationInfo(name string) (ApplicationInfo, error)
GetApplicationInfo returns information about application
func (*Node) GetPeerList ¶
GetPeerList returns list of connected nodes
func (*Node) GetProcessByName ¶
GetProcessByName returns Process associated with given name
func (*Node) GetProcessByPid ¶
GetProcessByPid returns Process by given pid
func (*Node) GetProcessList ¶
GetProcessList returns array of running process
func (*Node) IsProcessAlive ¶
IsProcessAlive returns true if the process with given pid is alive
func (*Node) LoadedApplications ¶
func (n *Node) LoadedApplications() []ApplicationInfo
LoadedApplications returns a list with information about the applications, which are loaded using ApplicatoinLoad
func (*Node) ProcessInfo ¶
func (n *Node) ProcessInfo(pid etf.Pid) (ProcessInfo, error)
ProcessInfo returns the details about given Pid
func (*Node) ProvideRPC ¶
ProvideRPC register given module/function as RPC method
func (*Node) RemoveStaticRoute ¶ added in v1.2.0
RemoveStaticRoute removes static route record from the EPMD client
func (*Node) ResolvePort ¶ added in v1.2.0
ResolvePort resolves port number for the given name. Returns -1 if not found
func (*Node) Spawn ¶
func (n *Node) Spawn(name string, opts ProcessOptions, object interface{}, args ...interface{}) (*Process, error)
Spawn create new process
func (*Node) Unregister ¶
func (*Node) VersionERTS ¶
func (*Node) VersionOTP ¶
func (*Node) WaitWithTimeout ¶
WaitWithTimeout waits until node stopped. Return ErrTimeout if given timeout is exceeded
func (*Node) WhichApplications ¶
func (n *Node) WhichApplications() []ApplicationInfo
WhichApplications returns a list with information about the applications that are currently running.
type NodeOptions ¶
type NodeOptions struct { ListenRangeBegin uint16 ListenRangeEnd uint16 Hidden bool EPMDPort uint16 DisableEPMDServer bool SendQueueLength int RecvQueueLength int FragmentationUnit int DisableHeaderAtomCache bool TLSmode TLSmodeType TLScrtServer string TLSkeyServer string TLScrtClient string TLSkeyClient string }
NodeOptions struct with bootstrapping options for CreateNode
type Process ¶
type Process struct { sync.RWMutex Context context.Context Kill context.CancelFunc Exit ProcessExitFunc Node *Node // contains filtered or unexported fields }
func (*Process) Call ¶
Call makes outgoing sync request in fashion of 'gen_call'. 'to' can be Pid, registered local name or a tuple {RegisteredName, NodeName}
func (*Process) CallRPCWithTimeout ¶
func (p *Process) CallRPCWithTimeout(timeout int, node, module, function string, args ...etf.Term) (etf.Term, error)
CallRPCWithTimeout evaluate rpc call with given node/MFA and timeout
func (*Process) CallWithTimeout ¶
CallWithTimeout makes outgoing sync request in fashiod of 'gen_call' with given timeout
func (*Process) Cast ¶
Cast sends a message in fashion of 'gen_cast'. 'to' can be a Pid, registered local name or a tuple {RegisteredName, NodeName}
func (*Process) CastAfter ¶
func (p *Process) CastAfter(to interface{}, message etf.Term, after time.Duration) context.CancelFunc
CastAfter simple wrapper for SendAfter to send '$gen_cast' message
func (*Process) DemonitorNode ¶
DemonitorNode removes monitor
func (*Process) DemonitorProcess ¶
DemonitorProcess removes monitor. Returns false if the given reference 'ref' wasn't found
func (*Process) GetChildren ¶
GetChildren returns list of children pid (Application, Supervisor)
func (*Process) GetTrapExit ¶ added in v1.2.0
GetTrapExit returns whether the trap was enabled on this process
func (*Process) Info ¶
func (p *Process) Info() ProcessInfo
Info returns detailed information about the process
func (*Process) ListEnv ¶
ListEnv returns map of configured environment variables. Process' environment is also inherited from environment variables of groupLeader (if its started as a child of Application/Supervisor)
func (*Process) MonitorNode ¶
MonitorNode creates monitor between the current process and node. If Node fails or does not exist, the message {nodedown, Node} is delivered to the process.
func (*Process) MonitorProcess ¶
MonitorProcess creates monitor between the processes. 'process' value can be: etf.Pid, registered local name etf.Atom or remote registered name etf.Tuple{Name etf.Atom, Node etf.Atom} When a process monitor is triggered, a 'DOWN' message sends that has the following pattern: {'DOWN', MonitorRef, Type, Object, Info} where Info has following values:
- the exit reason of the process
- 'noproc' (process did not exist at the time of monitor creation)
- 'noconnection' (no connection to the node where the monitored process resides)
Note: The monitor request is an asynchronous signal. That is, it takes time before the signal reaches its destination.
func (*Process) Send ¶
Send sends a message. 'to' can be a Pid, registered local name or a tuple {RegisteredName, NodeName}
func (*Process) SendAfter ¶
func (p *Process) SendAfter(to interface{}, message etf.Term, after time.Duration) context.CancelFunc
SendAfter starts a timer. When the timer expires, the message sends to the process identified by 'to'. 'to' can be a Pid, registered local name or a tuple {RegisteredName, NodeName}. Returns cancel function in order to discard sending a message
func (*Process) SetTrapExit ¶ added in v1.2.0
SetTrapExit enables/disables the trap on terminate process
type ProcessBehaviour ¶
type ProcessBehaviour interface {
Loop(*Process, ...interface{}) string // method which implements control flow of process
}
ProcessBehaviour interface contains methods you should implement to make own process behaviour
type ProcessExitFunc ¶
ProcessExitFunc initiate a graceful stopping process
type ProcessInfo ¶
type ProcessInfo struct { PID etf.Pid Name string CurrentFunction string Status string MessageQueueLen int Links []etf.Pid Monitors []etf.Pid MonitoredBy []etf.Pid Dictionary etf.Map TrapExit bool GroupLeader etf.Pid Reductions uint64 }
ProcessInfo struct with process details
type ProcessOptions ¶
type ProcessType ¶
type ProcessType = string
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
Supervisor is implementation of ProcessBehaviour interface
func (*Supervisor) Loop ¶ added in v1.2.0
func (sv *Supervisor) Loop(svp *Process, args ...interface{}) string
func (*Supervisor) StartChild ¶
func (sv *Supervisor) StartChild(parent *Process, specName string, args ...interface{}) (etf.Pid, error)
StartChild dynamically starts a child process with given name of child spec which is defined by Init call. Created process will use the same object (GenServer/Supervisor) you have defined in spec as a Child since it keeps pointer. You might use this object as a shared among the process you will create using this spec.
func (*Supervisor) StartChildWithSpec ¶
func (sv *Supervisor) StartChildWithSpec(parent *Process, spec SupervisorChildSpec, args ...interface{}) (etf.Pid, error)
StartChildWithSpec dynamically starts a child process with given child spec
type SupervisorBehaviour ¶ added in v1.2.0
type SupervisorBehaviour interface {
Init(args ...interface{}) SupervisorSpec
}
SupervisorBehaviour interface
type SupervisorChild ¶
type SupervisorChild = string
type SupervisorChildRestart ¶
type SupervisorChildRestart = string
type SupervisorChildShutdown ¶
type SupervisorChildShutdown int
SupervisorChildShutdown is an integer time-out value means that the supervisor tells the child process to terminate by calling Stop method and then wait for an exit signal with reason shutdown back from the child process. If no exit signal is received within the specified number of seconds, the child process is unconditionally terminated using Kill method. There are predefined values:
SupervisorChildShutdownBrutal (-1) SupervisorChildShutdownInfinity (0) - default value SupervisorChildShutdownTimeout5sec (5)
type SupervisorChildSpec ¶
type SupervisorChildSpec struct { Name string Child interface{} Args []interface{} Restart SupervisorChildRestart Shutdown SupervisorChildShutdown // contains filtered or unexported fields }
type SupervisorSpec ¶
type SupervisorSpec struct { Name string Children []SupervisorChildSpec Strategy SupervisorStrategy // contains filtered or unexported fields }
type SupervisorStrategy ¶
type SupervisorStrategy struct { Type SupervisorStrategyType Intensity uint16 Period uint16 }
type SupervisorStrategyType ¶
type SupervisorStrategyType = string
type TLSmodeType ¶ added in v1.2.0
type TLSmodeType string
TLSmodeType should be one of TLSmodeDisabled (default), TLSmodeAuto or TLSmodeStrict
const ( // TLSmodeDisabled no TLS encryption TLSmodeDisabled TLSmodeType = "" // TLSmodeAuto generate self-signed certificate TLSmodeAuto TLSmodeType = "auto" // TLSmodeStrict with validation certificate TLSmodeStrict TLSmodeType = "strict" )