gen

package
v1.999.300 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2024 License: MIT Imports: 12 Imported by: 18

Documentation

Index

Constants

View Source
const (
	ApplicationModeTemporary ApplicationMode = 1
	ApplicationModeTransient ApplicationMode = 2
	ApplicationModePermanent ApplicationMode = 3

	ApplicationStateLoaded   ApplicationState = 1
	ApplicationStateRunning  ApplicationState = 2
	ApplicationStateStopping ApplicationState = 3
)
View Source
const (
	LicenseMIT  string = "MIT"
	LicenseBSL1 string = "Business Source License 1.1"
)
View Source
const (
	CompressionDefault   CompressionLevel = 0
	CompressionBestSpeed CompressionLevel = 1
	CompressionBestSize  CompressionLevel = 2

	CompressionTypeGZIP CompressionType = "gzip"
	CompressionTypeLZW  CompressionType = "lzw"
	CompressionTypeZLIB CompressionType = "zlib"
)

Variables

View Source
var (
	DefaultRequestTimeout = 5

	DefaultCompressionType      CompressionType  = CompressionTypeGZIP
	DefaultCompressionLevel     CompressionLevel = CompressionDefault
	DefaultCompressionThreshold int              = 1024

	DefaultLogFilter = []LogLevel{
		LogLevelTrace,
		LogLevelDebug,
		LogLevelInfo,
		LogLevelWarning,
		LogLevelError,
		LogLevelPanic,
	}

	DefaultKeepAlivePeriod time.Duration = 15 * time.Second
	DefaultTCPBufferSize   int           = 65535
	DefaultPort            uint16        = 11144

	DefaultNetworkFlags = NetworkFlags{
		Enable:                       true,
		EnableRemoteSpawn:            true,
		EnableRemoteApplicationStart: true,
		EnableFragmentation:          false,
		EnableProxyTransit:           false,
		EnableProxyAccept:            true,
		EnableImportantDelivery:      true,
	}

	DefaultNetworkProxyFlags = NetworkProxyFlags{
		Enable:                       true,
		EnableRemoteSpawn:            false,
		EnableRemoteApplicationStart: false,
		EnableEncryption:             false,
		EnableImportantDelivery:      true,
	}

	DefaultLogLevels = []LogLevel{
		LogLevelSystem,
		LogLevelTrace,
		LogLevelDebug,
		LogLevelInfo,
		LogLevelWarning,
		LogLevelError,
		LogLevelPanic,
	}
)
View Source
var (
	ErrNameUnknown    = errors.New("unknown name")
	ErrParentUnknown  = errors.New("parent/leader is not set")
	ErrNodeTerminated = errors.New("node terminated")

	ErrProcessMailboxFull = errors.New("process mailbox is full")
	ErrProcessUnknown     = errors.New("unknown process")
	ErrProcessIncarnation = errors.New("process ID belongs to the previous incarnation")
	ErrProcessTerminated  = errors.New("process terminated")

	ErrMetaUnknown     = errors.New("unknown meta process")
	ErrMetaMailboxFull = errors.New("meta process mailbox is full")

	ErrApplicationUnknown   = errors.New("unknown application")
	ErrApplicationDepends   = errors.New("dependency fail")
	ErrApplicationState     = errors.New("application is in running/stopping state")
	ErrApplicationLoadPanic = errors.New("panic in application loading")
	ErrApplicationEmpty     = errors.New("application has no items")
	ErrApplicationName      = errors.New("application has no name")
	ErrApplicationStopping  = errors.New("application stopping is in progress")
	ErrApplicationRunning   = errors.New("application is still running")

	ErrTargetUnknown = errors.New("unknown target")
	ErrTargetExist   = errors.New("target is already exist")

	ErrRegistrarTerminated = errors.New("registrar client terminated")

	ErrAliasUnknown = errors.New("unknown alias")
	ErrAliasOwner   = errors.New("not an owner")
	ErrEventUnknown = errors.New("unknown event")
	ErrEventOwner   = errors.New("not an owner")
	ErrTaken        = errors.New("resource is taken")

	ErrAtomTooLong = errors.New("too long Atom (max: 255)")

	ErrTimeout     = errors.New("timed out")
	ErrUnsupported = errors.New("not supported")
	ErrUnknown     = errors.New("unknown")
	ErrNotAllowed  = errors.New("not allowed")

	ErrIncorrect       = errors.New("incorrect value or argument")
	ErrMalformed       = errors.New("malformed value")
	ErrResponseIgnored = errors.New("response ignored")
	ErrUnregistered    = errors.New("unregistered")
	ErrTooLarge        = errors.New("too large")

	ErrNetworkStopped = errors.New("network stack is stopped")
	ErrNoConnection   = errors.New("no connection")
	ErrNoRoute        = errors.New("no route")

	ErrInternal = errors.New("internal error")
)
View Source
var (
	TerminateReasonNormal   error = errors.New("normal")
	TerminateReasonKill     error = errors.New("kill")
	TerminateReasonPanic    error = errors.New("panic")
	TerminateReasonShutdown error = errors.New("shutdown")
)

Functions

func ReleaseMailboxMessage

func ReleaseMailboxMessage(m *MailboxMessage)

Types

type Acceptor

type Acceptor interface {
	Cookie() string
	SetCookie(cokie string)
	NetworkFlags() NetworkFlags
	SetNetworkFlags(flags NetworkFlags)
	MaxMessageSize() int
	SetMaxMessageSize(size int)
	Info() AcceptorInfo
}

type AcceptorInfo

type AcceptorInfo struct {
	Interface        string
	MaxMessageSize   int
	Flags            NetworkFlags
	TLS              bool
	CustomRegistrar  bool
	RegistrarServer  string
	RegistrarVersion Version
	HandshakeVersion Version
	ProtoVersion     Version
}

type AcceptorOptions

type AcceptorOptions struct {
	// Cookie cookie for the incoming connection to this acceptor. Leave it empty in
	// case of using the node's cookie.
	Cookie string
	// Hostname defines an interface for the listener. Default: takes from the node name.
	Host string
	// Port defines a listening port number for accepting incoming connections. Default 15000
	Port uint16
	// PortRange a range of the ports for the attempts to start listening:
	//   Starting from: <Port>
	//   Ending at: <Port> + <PortRange>
	PortRange uint16
	// TCP defines the TCP network. By default will be used IPv4 only.
	// For IPv6 use "tcp6". To listen on any available address use "tcp"
	TCP string
	// BufferSize defines buffer size for the TCP connection
	BufferSize int
	// MaxMessageSize set max message size. overrides gen.NetworkOptions.MaxMessageSize
	MaxMessageSize int

	Flags       NetworkFlags
	AtomMapping map[Atom]Atom

	CertManager        CertManager
	InsecureSkipVerify bool

	Registrar Registrar
	Handshake NetworkHandshake
	Proto     NetworkProto
}

type Alias

type Alias Ref

Alias

func (Alias) MarshalJSON

func (a Alias) MarshalJSON() ([]byte, error)

func (Alias) String

func (a Alias) String() string

String

type ApplicationBehavior

type ApplicationBehavior interface {
	// Load invoked on loading application using method ApplicationLoad of gen.Node interface.
	Load(node Node, args ...any) (ApplicationSpec, error)
	// Start invoked once the application started
	Start(mode ApplicationMode)
	// Terminate invoked once the application stopped
	Terminate(reason error)
}

type ApplicationDepends

type ApplicationDepends struct {
	Applications []Atom
	Network      bool
}

type ApplicationInfo

type ApplicationInfo struct {
	Name        Atom
	Weight      int
	Description string
	Version     Version
	Env         map[Env]any
	Depends     ApplicationDepends
	Mode        ApplicationMode
	State       ApplicationState
	Parent      Atom
	Uptime      int64
	Group       []PID
}

type ApplicationMemberSpec

type ApplicationMemberSpec struct {
	Factory ProcessFactory
	Options ProcessOptions
	Name    Atom
	Args    []any
}

ApplicationMemberSpec

type ApplicationMode

type ApplicationMode int

func (ApplicationMode) MarshalJSON

func (am ApplicationMode) MarshalJSON() ([]byte, error)

func (ApplicationMode) String

func (am ApplicationMode) String() string

type ApplicationOptions

type ApplicationOptions struct {
	Env      map[Env]any
	LogLevel LogLevel
}

type ApplicationOptionsExtra

type ApplicationOptionsExtra struct {
	ApplicationOptions
	CorePID      PID
	CoreEnv      map[Env]any
	CoreLogLevel LogLevel
}

type ApplicationRoute

type ApplicationRoute struct {
	Node   Atom
	Name   Atom
	Weight int
	Mode   ApplicationMode
	State  ApplicationState
}

type ApplicationSpec

type ApplicationSpec struct {
	Name        Atom
	Description string
	Version     Version
	Depends     ApplicationDepends
	Env         map[Env]any
	Group       []ApplicationMemberSpec
	Mode        ApplicationMode
	Weight      int
	LogLevel    LogLevel
}

ApplicationSpec

type ApplicationState

type ApplicationState int32

func (ApplicationState) MarshalJSON

func (as ApplicationState) MarshalJSON() ([]byte, error)

func (ApplicationState) String

func (as ApplicationState) String() string

type Atom

type Atom string

Atom is a special kind of string used for process names and node names. The max allowed length is 255 bytes. Exceed this limit causes disability to send it over the network. Keep this in mind.

const (
	CoreEvent Atom = "core"
)

func (Atom) CRC32

func (a Atom) CRC32() string

func (Atom) Host

func (a Atom) Host() string

func (Atom) String

func (a Atom) String() string

type CancelFunc

type CancelFunc func() bool

type CertManager

type CertManager interface {
	Update(cert tls.Certificate)
	GetCertificateFunc() func(*tls.ClientHelloInfo) (*tls.Certificate, error)
	GetCertificate() tls.Certificate
}

func CreateCertManager

func CreateCertManager(cert tls.Certificate) CertManager

type Compression

type Compression struct {
	// Enable enables compression for all outgoing messages having size
	// greater than the defined threshold.
	Enable bool
	// Type defines type of compression. Use gen.CompressionTypeZLIB or gen.CompressionTypeLZW. By default is using gen.CompressionTypeGZIP
	Type CompressionType
	// Level defines compression level. Use gen.CompressionBestSize or gen.CompressionBestSpeed. By default is using gen.CompressionDefault
	Level CompressionLevel
	// Threshold defines the minimal message size for the compression.
	// Messages less of this threshold will not be compressed.
	Threshold int
}

type CompressionLevel

type CompressionLevel int

func (CompressionLevel) MarshalJSON

func (cl CompressionLevel) MarshalJSON() ([]byte, error)

func (CompressionLevel) String

func (cl CompressionLevel) String() string

type CompressionType

type CompressionType string

func (CompressionType) ID

func (ct CompressionType) ID() uint8

type Connection

type Connection interface {
	Node() RemoteNode

	// Methods for sending async message to the remote process
	SendPID(from PID, to PID, options MessageOptions, message any) error
	SendProcessID(from PID, to ProcessID, options MessageOptions, message any) error
	SendAlias(from PID, to Alias, options MessageOptions, message any) error

	SendEvent(from PID, options MessageOptions, message MessageEvent) error
	SendExit(from PID, to PID, reason error) error
	SendResponse(from PID, to PID, options MessageOptions, response any) error
	SendResponseError(from PID, to PID, options MessageOptions, err error) error

	// target terminated
	SendTerminatePID(target PID, reason error) error
	SendTerminateProcessID(target ProcessID, reason error) error
	SendTerminateAlias(target Alias, reason error) error
	SendTerminateEvent(target Event, reason error) error

	// Methods for sending sync request to the remote process
	CallPID(from PID, to PID, options MessageOptions, message any) error
	CallProcessID(from PID, to ProcessID, options MessageOptions, message any) error
	CallAlias(from PID, to Alias, options MessageOptions, message any) error

	// Links
	LinkPID(pid PID, target PID) error
	UnlinkPID(pid PID, target PID) error

	LinkProcessID(pid PID, target ProcessID) error
	UnlinkProcessID(pid PID, target ProcessID) error

	LinkAlias(pid PID, target Alias) error
	UnlinkAlias(pid PID, target Alias) error

	LinkEvent(pid PID, target Event) ([]MessageEvent, error)
	UnlinkEvent(pid PID, targer Event) error

	// Monitors
	MonitorPID(pid PID, target PID) error
	DemonitorPID(pid PID, target PID) error

	MonitorProcessID(pid PID, target ProcessID) error
	DemonitorProcessID(pid PID, target ProcessID) error

	MonitorAlias(pid PID, target Alias) error
	DemonitorAlias(pid PID, target Alias) error

	MonitorEvent(pid PID, target Event) ([]MessageEvent, error)
	DemonitorEvent(pid PID, targer Event) error

	RemoteSpawn(name Atom, options ProcessOptionsExtra) (PID, error)

	Join(c net.Conn, id string, dial NetworkDial, tail []byte) error
	Terminate(reason error)
}

type Core

type Core interface {
	// sending message
	RouteSendPID(from PID, to PID, options MessageOptions, message any) error
	RouteSendProcessID(from PID, to ProcessID, options MessageOptions, message any) error
	RouteSendAlias(from PID, to Alias, options MessageOptions, message any) error

	RouteSendEvent(from PID, token Ref, options MessageOptions, message MessageEvent) error
	RouteSendExit(from PID, to PID, reason error) error
	RouteSendResponse(from PID, to PID, options MessageOptions, message any) error
	RouteSendResponseError(from PID, to PID, options MessageOptions, err error) error

	// call requests
	RouteCallPID(from PID, to PID, options MessageOptions, message any) error
	RouteCallProcessID(from PID, to ProcessID, options MessageOptions, message any) error
	RouteCallAlias(from PID, to Alias, options MessageOptions, message any) error

	// linking requests
	RouteLinkPID(pid PID, target PID) error
	RouteUnlinkPID(pid PID, target PID) error

	RouteLinkProcessID(pid PID, target ProcessID) error
	RouteUnlinkProcessID(pid PID, target ProcessID) error

	RouteLinkAlias(pid PID, target Alias) error
	RouteUnlinkAlias(pid PID, target Alias) error

	RouteLinkEvent(pid PID, target Event) ([]MessageEvent, error)
	RouteUnlinkEvent(pid PID, target Event) error

	// monitoring requests
	RouteMonitorPID(pid PID, target PID) error
	RouteDemonitorPID(pid PID, target PID) error

	RouteMonitorProcessID(pid PID, target ProcessID) error
	RouteDemonitorProcessID(pid PID, target ProcessID) error

	RouteMonitorAlias(pid PID, target Alias) error
	RouteDemonitorAlias(pid PID, target Alias) error

	RouteMonitorEvent(pid PID, target Event) ([]MessageEvent, error)
	RouteDemonitorEvent(pid PID, target Event) error

	// target termination
	RouteTerminatePID(target PID, reason error) error
	RouteTerminateProcessID(target ProcessID, reason error) error
	RouteTerminateEvent(target Event, reason error) error
	RouteTerminateAlias(terget Alias, reason error) error

	RouteSpawn(node Atom, name Atom, options ProcessOptionsExtra, source Atom) (PID, error)
	RouteApplicationStart(name Atom, mode ApplicationMode, options ApplicationOptionsExtra, source Atom) error

	RouteNodeDown(node Atom, reason error)

	MakeRef() Ref
	Name() Atom
	Creation() int64

	PID() PID
	LogLevel() LogLevel
	Security() SecurityOptions
	EnvList() map[Env]any
}

type DefaultLoggerOptions

type DefaultLoggerOptions struct {
	// Disable makes node to disable default logger
	Disable bool
	// TimeFormat enables output time in the defined format. See https://pkg.go.dev/time#pkg-constants
	// Not defined format makes output time as a timestamp in nanoseconds.
	TimeFormat string
	// IncludeBehavior includes process/meta behavior to the log message
	IncludeBehavior bool
	// IncludeName includes registered process name to the log message
	IncludeName bool
	// Filter enables filtering log messages.
	Filter []LogLevel
	// Output defines output for the log messages. By default it uses os.Stdout
	Output io.Writer
}

DefaultLoggerOptions

type Env

type Env string

Env

func (Env) MarshalJSON

func (e Env) MarshalJSON() ([]byte, error)

func (Env) String

func (e Env) String() string

type Event

type Event struct {
	Name Atom
	Node Atom
}

Event

func (Event) MarshalJSON

func (e Event) MarshalJSON() ([]byte, error)

func (Event) String

func (e Event) String() string

type EventOptions

type EventOptions struct {
	Notify bool
	Buffer int
}

type HandshakeOptions

type HandshakeOptions struct {
	Cookie         string
	Flags          NetworkFlags
	CertManager    CertManager
	MaxMessageSize int
}

type HandshakeResult

type HandshakeResult struct {
	HandshakeVersion Version

	ConnectionID       string
	Peer               Atom
	PeerCreation       int64
	PeerVersion        Version      // peer's version (gen.Node.Version())
	PeerFlags          NetworkFlags // peer's flags
	PeerMaxMessageSize int

	NodeFlags          NetworkFlags
	NodeMaxMessageSize int

	AtomMapping map[Atom]Atom

	// Tail if something is left in the buffer after the handshaking we should
	// pass it to the proto handler
	Tail []byte
	// Custom allows passing the custom data to the proto handler
	Custom any
}

type Log

type Log interface {
	Level() LogLevel
	SetLevel(level LogLevel) error

	Logger() string
	SetLogger(name string)

	Trace(format string, args ...any)
	Debug(format string, args ...any)
	Info(format string, args ...any)
	Warning(format string, args ...any)
	Error(format string, args ...any)
	Panic(format string, args ...any)
}

type LogLevel

type LogLevel int

LogLevel

const (
	LogLevelSystem LogLevel = -100

	LogLevelTrace    LogLevel = -2
	LogLevelDebug    LogLevel = -1
	LogLevelDefault  LogLevel = 0 // inherite from node/app/parent process
	LogLevelInfo     LogLevel = 1
	LogLevelWarning  LogLevel = 2
	LogLevelError    LogLevel = 3
	LogLevelPanic    LogLevel = 4
	LogLevelDisabled LogLevel = 5
)

func (LogLevel) MarshalJSON

func (l LogLevel) MarshalJSON() ([]byte, error)

func (LogLevel) String

func (l LogLevel) String() string

type LogOptions

type LogOptions struct {
	// Level default logging level for node
	Level LogLevel

	// DefaultLogger options
	DefaultLogger DefaultLoggerOptions

	// Loggers add extra loggers on start
	Loggers []Logger
}

LogOptions

type Logger

type Logger struct {
	Name   string
	Logger LoggerBehavior
	Filter []LogLevel
}

type LoggerBehavior

type LoggerBehavior interface {
	Log(message MessageLog)
	Terminate()
}

func CreateDefaultLogger

func CreateDefaultLogger(options DefaultLoggerOptions) LoggerBehavior

type LoggerInfo

type LoggerInfo struct {
	Name     string
	Behavior string
	Levels   []LogLevel
}

type MailboxMessage

type MailboxMessage struct {
	From    PID
	Ref     Ref
	Type    MailboxMessageType
	Target  any
	Message any
}

func TakeMailboxMessage

func TakeMailboxMessage() *MailboxMessage

type MailboxMessageType

type MailboxMessageType int
const (
	MailboxMessageTypeRegular MailboxMessageType = 0
	MailboxMessageTypeRequest MailboxMessageType = 1
	MailboxMessageTypeEvent   MailboxMessageType = 2
	MailboxMessageTypeExit    MailboxMessageType = 3
	MailboxMessageTypeInspect MailboxMessageType = 4 // for the observer's purposes
)

type MailboxQueues

type MailboxQueues struct {
	Main   int64
	System int64
	Urgent int64
	Log    int64
}

type MessageDownAlias

type MessageDownAlias struct {
	Alias  Alias
	Reason error
}

MessageDownAlias

type MessageDownEvent

type MessageDownEvent struct {
	Event  Event
	Reason error
}

MessageDownEvent

type MessageDownNode

type MessageDownNode struct {
	Name Atom
}

MessageDownNode

type MessageDownPID

type MessageDownPID struct {
	PID    PID
	Reason error
}

MessageDownPID

type MessageDownProcessID

type MessageDownProcessID struct {
	ProcessID ProcessID
	Reason    error
}

MessageDownProcessID

type MessageDownProxy

type MessageDownProxy struct {
	Node   Atom
	Proxy  Atom
	Reason error
}

MessageDownProxy

type MessageEvent

type MessageEvent struct {
	Event     Event
	Timestamp int64
	Message   any
}

MessageEvent

type MessageEventStart

type MessageEventStart struct {
	Name Atom
}

MessageEventStart

type MessageEventStop

type MessageEventStop struct {
	Name Atom
}

MessageEventStop

type MessageExitAlias

type MessageExitAlias struct {
	Alias  Alias
	Reason error
}

MessageExitAlias

type MessageExitEvent

type MessageExitEvent struct {
	Event  Event
	Reason error
}

MessageExitEvent

type MessageExitNode

type MessageExitNode struct {
	Name Atom
}

MessageExitNode

type MessageExitPID

type MessageExitPID struct {
	PID    PID
	Reason error
}

MessageExitPID

type MessageExitProcessID

type MessageExitProcessID struct {
	ProcessID ProcessID
	Reason    error
}

MessageExitProcessID

type MessageFallback

type MessageFallback struct {
	PID     PID
	Tag     string
	Target  any
	Message any
}

MessageFallback

type MessageLog

type MessageLog struct {
	Time   time.Time
	Level  LogLevel
	Source any // MessageLogProcess, MessageLogNode, MessageLogNetwork, MessageLogMeta
	Format string
	Args   []any
}

MessageLog

type MessageLogMeta

type MessageLogMeta struct {
	Node     Atom
	Parent   PID
	Meta     Alias
	Behavior string
}

MessageLogMeta

type MessageLogNetwork

type MessageLogNetwork struct {
	Node     Atom
	Peer     Atom
	Creation int64
}

type MessageLogNode

type MessageLogNode struct {
	Node     Atom
	Creation int64
}

MessageLogNode

type MessageLogProcess

type MessageLogProcess struct {
	Node     Atom
	PID      PID
	Name     Atom
	Behavior string
}

MessageLogProcess

type MessageOptions

type MessageOptions struct {
	Ref               Ref
	Priority          MessagePriority
	Compression       Compression
	KeepNetworkOrder  bool
	ImportantDelivery bool
}

type MessagePriority

type MessagePriority int
const MessagePriorityHigh MessagePriority = 1
const MessagePriorityMax MessagePriority = 2
const MessagePriorityNormal MessagePriority = 0 // default

func (MessagePriority) MarshalJSON

func (mp MessagePriority) MarshalJSON() ([]byte, error)

func (MessagePriority) String

func (mp MessagePriority) String() string

type MetaBehavior

type MetaBehavior interface {
	Init(process MetaProcess) error
	Start() error
	HandleMessage(from PID, message any) error
	HandleCall(from PID, ref Ref, request any) (any, error)
	Terminate(reason error)

	HandleInspect(from PID, item ...string) map[string]string
}

type MetaInfo

type MetaInfo struct {
	ID              Alias
	Parent          PID
	Application     Atom
	Behavior        string
	MailboxSize     int64
	MailboxQueues   MailboxQueues
	MessagePriority MessagePriority
	MessagesIn      uint64
	MessagesOut     uint64
	LogLevel        LogLevel
	Uptime          int64
	State           MetaState
}

MetaInfo

type MetaOptions

type MetaOptions struct {
	MailboxSize  int64
	SendPriority MessagePriority
	LogLevel     LogLevel
}

type MetaProcess

type MetaProcess interface {
	ID() Alias
	Parent() PID
	Send(to any, message any) error
	SendImportant(to any, message any) error
	SendWithPriority(to any, message any, priority MessagePriority) error
	Spawn(behavior MetaBehavior, options MetaOptions) (Alias, error)
	Env(name Env) (any, bool)
	EnvList() map[Env]any
	Log() Log
}

type MetaState

type MetaState int32
const (
	MetaStateSleep      MetaState = 1
	MetaStateRunning    MetaState = 2
	MetaStateTerminated MetaState = 4
)

func (MetaState) MarshalJSON

func (p MetaState) MarshalJSON() ([]byte, error)

func (MetaState) String

func (p MetaState) String() string

type Network

type Network interface {
	Registrar() (Registrar, error)
	Cookie() string
	SetCookie(cookie string) error
	MaxMessageSize() int
	SetMaxMessageSize(size int)
	NetworkFlags() NetworkFlags
	SetNetworkFlags(flags NetworkFlags)
	Acceptors() ([]Acceptor, error)

	// Node returns existing connection with the given node
	Node(name Atom) (RemoteNode, error)
	// GetNode attempts to connect to the given node if the connection doesn't exist.
	// Otherwise, it returns the existing connection.
	GetNode(name Atom) (RemoteNode, error)
	// GetNodeWithRoute attempts to connect to the given node using provided route
	GetNodeWithRoute(name Atom, route NetworkRoute) (RemoteNode, error)

	// Nodes return list of connected nodes
	Nodes() []Atom

	// AddRoute add static route
	AddRoute(match string, route NetworkRoute, weight int) error
	RemoveRoute(match string) error
	Route(name Atom) ([]NetworkRoute, error)

	AddProxyRoute(match string, proxy NetworkProxyRoute, weight int) error
	RemoveProxyRoute(match string) error
	ProxyRoute(name Atom) ([]NetworkProxyRoute, error)

	RegisterProto(proto NetworkProto)
	RegisterHandshake(handshake NetworkHandshake)

	// EnableSpawn allows the starting of the given process by the remote node(s)
	// Leaving argument "nodes" empty makes spawning this process by any remote node
	EnableSpawn(name Atom, factory ProcessFactory, nodes ...Atom) error
	DisableSpawn(name Atom, nodes ...Atom) error

	// EnableApplicationStart allows the starting of the given application by the remote node(s).
	// Leaving argument "nodes" empty makes starting this application by any remote node.
	EnableApplicationStart(name Atom, nodes ...Atom) error
	DisableApplicationStart(name Atom, nodes ...Atom) error

	Info() (NetworkInfo, error)
	Mode() NetworkMode
}

type NetworkApplicationStartInfo

type NetworkApplicationStartInfo struct {
	Name  Atom
	Nodes []Atom
}

type NetworkDial

type NetworkDial func(dsn, id string) (net.Conn, []byte, error)

type NetworkFlags

type NetworkFlags struct {
	// Enable enable flags customization.
	Enable bool
	// EnableRemoteSpawn accepts remote spawn request
	EnableRemoteSpawn bool
	// EnableRemoteApplicationStart accepts remote request to start application
	EnableRemoteApplicationStart bool
	// EnableFragmentation enables support fragmentation messages
	EnableFragmentation bool
	// EnableProxyTransit enables support for transit proxy connection
	EnableProxyTransit bool
	// EnableProxyAccept enables support for incoming proxy connection
	EnableProxyAccept bool
	// EnableImportantDelivery enables support 'important' flag
	EnableImportantDelivery bool
}

NetworkFlags

func (NetworkFlags) MarshalEDF

func (nf NetworkFlags) MarshalEDF(w io.Writer) error

we must be able to extend this structure by introducing new features. it is using in the handshake process. to keep capability use the custom marshaling for this type.

func (*NetworkFlags) UnmarshalEDF

func (nf *NetworkFlags) UnmarshalEDF(buf []byte) error

type NetworkHandshake

type NetworkHandshake interface {
	NetworkFlags() NetworkFlags
	// Start initiates handshake process.
	// Cert value has CertManager that was used to create this connection
	Start(NodeHandshake, net.Conn, HandshakeOptions) (HandshakeResult, error)
	// Join is invoking within the NetworkDial to shortcut the handshake process
	Join(NodeHandshake, net.Conn, string, HandshakeOptions) ([]byte, error)
	// Accept accepts handshake process initiated by another side of this connection.
	Accept(NodeHandshake, net.Conn, HandshakeOptions) (HandshakeResult, error)
	// Version
	Version() Version
}

Handshake defines handshake interface

type NetworkInfo

type NetworkInfo struct {
	Mode NetworkMode

	Registrar        RegistrarInfo
	Acceptors        []AcceptorInfo
	MaxMessageSize   int
	HandshakeVersion Version
	ProtoVersion     Version

	Nodes []Atom

	Routes      []RouteInfo
	ProxyRoutes []ProxyRouteInfo

	Flags                   NetworkFlags
	EnabledSpawn            []NetworkSpawnInfo
	EnabledApplicationStart []NetworkApplicationStartInfo
}

type NetworkMode

type NetworkMode int
const (
	// NetworkModeEnabled default network mode for the node. It makes node to
	// register on the registrar services providing the port number for the
	// incomming connections
	NetworkModeEnabled NetworkMode = 0

	// NerworkModeHidden makes node to start network with disabled acceptor(s) for the incomming connections.
	NetworkModeHidden NetworkMode = 1

	// NetworkModeDisabled disables networking for the node entirely.
	NetworkModeDisabled NetworkMode = -1
)

func (NetworkMode) MarshalJSON

func (nm NetworkMode) MarshalJSON() ([]byte, error)

func (NetworkMode) String

func (nm NetworkMode) String() string

type NetworkOptions

type NetworkOptions struct {
	Mode NetworkMode
	// Cookie
	Cookie string
	// Flags
	Flags NetworkFlags
	// Registrar default registrar for outgoing connections
	Registrar Registrar
	// Handshake set default handshake
	Handshake NetworkHandshake
	// Proto set default proto
	Proto NetworkProto

	// Acceptors node can have multiple acceptors at once
	Acceptors []AcceptorOptions
	// InsecureSkipVerify skips the certificate verification
	InsecureSkipVerify bool
	// MaxMessageSize limit the message size for the incoming messages.
	MaxMessageSize int
	// ProxyAccept options for incomming proxy connections
	ProxyAccept ProxyAcceptOptions
	// ProxyTransit options for the proxy connections through this node
	ProxyTransit ProxyTransitOptions
}

NetworkOptions

type NetworkProto

type NetworkProto interface {
	// NewConnection
	NewConnection(core Core, result HandshakeResult, log Log) (Connection, error)
	// Serve connection. Argument dial is the closure to create TCP connection with invoking
	// NetworkHandshake.Join inside to shortcut the handshake process
	Serve(conn Connection, dial NetworkDial) error
	// Version
	Version() Version
}

type NetworkProxyFlags

type NetworkProxyFlags struct {
	Enable                       bool
	EnableRemoteSpawn            bool
	EnableRemoteApplicationStart bool
	EnableEncryption             bool
	EnableImportantDelivery      bool
}

NetworkProxyFlags

func (NetworkProxyFlags) MarshalEDF

func (npf NetworkProxyFlags) MarshalEDF(w io.Writer) error

func (*NetworkProxyFlags) UnmarshalEDF

func (npf *NetworkProxyFlags) UnmarshalEDF(buf []byte) error

type NetworkProxyRoute

type NetworkProxyRoute struct {
	Resolver Resolver
	Route    ProxyRoute

	Cookie string
	Flags  NetworkProxyFlags
	MaxHop int // DefaultProxyMaxHop == 8
}

type NetworkRoute

type NetworkRoute struct {
	Resolver Resolver
	Route    Route

	Cookie             string
	Cert               CertManager
	InsecureSkipVerify bool
	Flags              NetworkFlags

	AtomMapping map[Atom]Atom

	LogLevel LogLevel
}

type NetworkSpawnInfo

type NetworkSpawnInfo struct {
	Name     Atom
	Behavior string
	Nodes    []Atom
}

type Node

type Node interface {
	// Name returns node name
	Name() Atom
	// IsAlive returns true if node is still alive
	IsAlive() bool
	// Uptime returns node uptime in seconds. Returns 0 if node is stopped.
	Uptime() int64
	// Version returns node version
	Version() Version
	// FrameworkVersion returns framework version
	FrameworkVersion() Version
	// Info returns summary information about this node
	Info() (NodeInfo, error)
	// EnvList returns a map of configured Node environment variables.
	EnvList() map[Env]any
	// SetEnv set node environment variable with given name. Use nil value to remove variable with given name.
	SetEnv(name Env, value any)
	// Env returns value associated with given environment name.
	Env(name Env) (any, bool)

	// Spawn spawns a new process
	Spawn(factory ProcessFactory, options ProcessOptions, args ...any) (PID, error)
	// SpawnRegister spawns a new process and register associated name with it
	SpawnRegister(register Atom, factory ProcessFactory, options ProcessOptions, args ...any) (PID, error)

	// RegisterName register associates the name with the given PID so you can address messages
	// to this process using gen.ProcessID{<name>, <nodename>}. Returns error if this process
	// is already has registered name.
	RegisterName(name Atom, pid PID) error

	// UnregisterName unregister associated name. Returns PID that this name belonged to.
	UnregisterName(name Atom) (PID, error)

	// MetaInfo returns summary information about given meta process
	MetaInfo(meta Alias) (MetaInfo, error)

	// ProcessInfo returns short summary information about given process
	ProcessInfo(pid PID) (ProcessInfo, error)

	// ProcessList returns the list of the processes
	ProcessList() ([]PID, error)

	// ProcessListShortInfo returns the list of the processes with short information
	// for the given range of process identifiers (gen.PID.ID)
	ProcessListShortInfo(start, limit int) ([]ProcessShortInfo, error)

	// ProcessState returns state of the given process:
	// - ProcessStateSleep (process has no messages)
	// - ProcessStateRunning (process is handling its mailbox)
	// - ProcessStateTerminated (final state of the process lifespan before it will be removed
	//   removed from the node)
	// - ProcessStateZombee (process was killed by node being in the running state).
	ProcessState(pid PID) (ProcessState, error)

	// ApplicationLoad loads application to the node. To start it use ApplicationStart method.
	// Returns the name of loaded application. Returns error gen.ErrTaken if application name
	// is already registered in the node.
	ApplicationLoad(app ApplicationBehavior, args ...any) (Atom, error)

	// ApplcationInfo returns the short information about the given application.
	// Returns error gen.ErrApplicationUnknown if it does not exist in the node
	ApplicationInfo(name Atom) (ApplicationInfo, error)

	// ApplicationUnload unloads application from the node. Returns gen.ErrApplicationRunning
	// if given application is already started (must be stopped before the unloading).
	// Or returns error gen.ErrApplicationUnknown if it does not exist in the node.
	ApplicationUnload(name Atom) error

	// ApplicationStart starts application with its children processes. Starting mode is according
	// to the defined in the gen.ApplicationSpec.Mode
	ApplicationStart(name Atom, options ApplicationOptions) error

	// ApplicationStartTemporary starts application in temporary mode overriding the value
	// of gen.ApplicationSpec.Mode
	ApplicationStartTemporary(name Atom, options ApplicationOptions) error

	// ApplicationStartTransient starts application in transient mode overriding the value
	// of gen.ApplicationSpec.Mode
	ApplicationStartTransient(name Atom, options ApplicationOptions) error

	// ApplicationStartPermanent starts application in permanent mode overriding the value
	// of gen.ApplicationSpec.Mode
	ApplicationStartPermanent(name Atom, options ApplicationOptions) error

	// ApplicationStop stops the given applications, awaiting all children to be stopped.
	// The default waiting time is 5 seconds. Returns error gen.ErrApplicationStopping
	// if application is still stopping. Once the application is stopped it can be unloaded
	// from the node using ApplicationUnload.
	ApplicationStop(name Atom) error

	// ApplicationStopForce force to kill all children, no awaiting the termination of children processes.
	ApplicationStopForce(name Atom) error

	// ApplicationStopWithTimeout stops the given applications, awaiting all children to be stopped
	// during the given period of time. Returns gen.ErrApplicationStopping on timeout.
	ApplicationStopWithTimeout(name Atom, timeout time.Duration) error

	// Applications return list of all applications (loaded and started).
	Applications() []Atom
	// ApplicationsRunning return list of all running applications
	ApplicationsRunning() []Atom

	NetworkStart(options NetworkOptions) error
	NetworkStop() error
	Network() Network

	CertManager() CertManager

	Security() SecurityOptions

	Stop()
	StopForce()

	// Wait waits node termination
	Wait()
	// WaitWithTimeout waits node termination with the given period of time
	WaitWithTimeout(timeout time.Duration) error

	// Kill terminates the given process. Can be used for the local process only.
	Kill(pid PID) error

	// Send sends a message to the given process.
	Send(to any, message any) error

	// SendEvent sends event message to the subscribers (to the processes that made link/monitor
	// on this event). Event must be registered with RegisterEvent method.
	SendEvent(name Atom, token Ref, options MessageOptions, message any) error

	// RegisterEvent registers a new event. Returns a reference as the token
	// for sending events. Unregistering this event is allowed to the node only.
	// Sending an event can be done using SendEvent method with the provided token.
	RegisterEvent(name Atom, options EventOptions) (Ref, error)

	// UnregisterEvent unregisters an event. Can be used for the registered
	// events by the node.
	UnregisterEvent(name Atom) error

	// SendExit sends graceful termination request to the process.
	SendExit(pid PID, reason error) error

	// Log returns gen.Log interface
	Log() Log

	// LogLevelProcess returns logging level for the given process
	LogLevelProcess(pid PID) (LogLevel, error)

	// SetLogLevelProcess allows set logging level for the given process
	SetLogLevelProcess(pid PID, level LogLevel) error

	// LogLevelMeta returns logging level for the given meta process
	LogLevelMeta(meta Alias) (LogLevel, error)

	// SetLogLevelMeta allows set logging level for the given meta process
	SetLogLevelMeta(meta Alias, level LogLevel) error

	// Loggers returns list of loggers
	Loggers() []string

	// LoggerAdd makes process to receive log messages gen.MessageLogNode, gen.MessageLogProcess
	LoggerAddPID(pid PID, name string, filter ...LogLevel) error

	// LoggerAdd allows to add a custom logger
	LoggerAdd(name string, logger LoggerBehavior, filter ...LogLevel) error

	// LoggerDelete removes process from the loggers list
	LoggerDeletePID(pid PID)

	// LoggerDeleteCustom removes custom logger from the logger list
	LoggerDelete(name string)

	// LoggerLevels returns list of log levels for the given logger
	LoggerLevels(name string) []LogLevel

	// MakeRef creates an unique reference within this node
	MakeRef() Ref

	// Commercial returns list of component versions with a commercial license (gen.LicenseBSL1)
	Commercial() []Version

	// PID returns virtual PID of the core. This PID is using as a source
	// for the messages sent by node using methods Send, SendExit or SendEvent
	// and as a parent PID for the spawned process by the node
	PID() PID
	Creation() int64

	// SetCTRLC allows you to catch Ctrl+C to enable/disable debug level for the node
	// Twice Ctrl+C - to stop node gracefully
	SetCTRLC(enable bool)
}

type NodeHandshake

type NodeHandshake interface {
	Name() Atom
	Creation() int64
	Version() Version
}

NodeHandshake bridge interface from Node to the Handshake

type NodeInfo

type NodeInfo struct {
	Name       Atom
	Uptime     int64
	Version    Version
	Framework  Version
	Commercial []Version

	Env      map[Env]any // gen.NodeOptions.Security.ExposeEnvInfo must be enabled to reveal this data
	LogLevel LogLevel
	Loggers  []LoggerInfo

	ProcessesTotal   int64
	ProcessesRunning int64
	ProcessesZombee  int64

	RegisteredAliases int64
	RegisteredNames   int64
	RegisteredEvents  int64

	ApplicationsTotal   int64
	ApplicationsRunning int64

	MemoryUsed  uint64
	MemoryAlloc uint64

	UserTime   int64
	SystemTime int64
}

type NodeOptions

type NodeOptions struct {
	// Applications application list that must be started
	Applications []ApplicationBehavior
	// Env node environment
	Env map[Env]any
	// Network
	Network NetworkOptions
	// CertManager
	CertManager CertManager
	// Security options
	Security SecurityOptions
	// Log options for the defaulf logger
	Log LogOptions
	// Version sets the version details for your node
	Version Version
}

NodeOptions defines bootstrapping options for the node

type NodeRegistrar

type NodeRegistrar interface {
	Name() Atom
	RegisterEvent(name Atom, options EventOptions) (Ref, error)
	UnregisterEvent(name Atom) error
	SendEvent(name Atom, token Ref, options MessageOptions, message any) error
	Log() Log
}

NodeRegistrar bridge interface from Node to the Registrar

type PID

type PID struct {
	Node     Atom
	ID       uint64
	Creation int64
}

PID

func (PID) MarshalJSON

func (p PID) MarshalJSON() ([]byte, error)

func (PID) String

func (p PID) String() string

String

type Process

type Process interface {
	// Node returns Node interface
	Node() Node

	// Name returns registered name associated with this process
	Name() Atom

	// PID returns identificator belonging to the process
	PID() PID

	// Leader returns group leader process. Usually it points to the application (or supervisor) process. Otherwise, it has the same value as parent.
	Leader() PID

	// Parent returns parent process.
	Parent() PID

	// Uptime returns process uptime in seconds
	Uptime() int64

	// Spawn creates a child process. Terminating the parent process
	// doesn't cause terminating this process.
	Spawn(factory ProcessFactory, options ProcessOptions, args ...any) (PID, error)

	// Spawn creates a child process with associated name.
	SpawnRegister(register Atom, factory ProcessFactory, options ProcessOptions, args ...any) (PID, error)

	// SpawnMeta creates a meta process. Returned alias is associated with this process and other
	// processes can send messages (using Send method) or make the requests (with Call method)
	// to this meta process.
	SpawnMeta(behavior MetaBehavior, options MetaOptions) (Alias, error)

	// RemoteSpawn makes request to the remote node to spawn a new process. See also ProvideSpawn method.
	RemoteSpawn(node Atom, name Atom, options ProcessOptions, args ...any) (PID, error)
	// RemoteSpawnRegister makes request to the remote node to spawn a new process and register it there
	// with the given rigistered name.
	RemoteSpawnRegister(node Atom, name Atom, register Atom, options ProcessOptions, args ...any) (PID, error)

	// State returns current process state. Usually, it returns gen.ProcessStateRunning.
	// But, If node has killed this process during the handling of its mailbox,
	// it returns gen.ProcessStateZombee, which means this process won't receive any new messages,
	// and most of the gen.Process methods won't be working returning gen.ErrNotAllowed.
	State() ProcessState

	// RegisterName register associates the name with PID so you can address messages to this
	// process using gen.ProcessID{<name>, <nodename>}. Returns error if this process is already
	// has registered name.
	RegisterName(name Atom) error

	// UnregisterName unregister associated name.
	UnregisterName() error

	// EnvList returns a map of configured environment variables.
	// It also includes environment variables from the GroupLeader, Parent and Node.
	// which are overlapped by priority: Process(Parent(GroupLeader(Node)))
	EnvList() map[Env]any

	// SetEnv set environment variable with given name. Use nil value to remove variable with given name.
	SetEnv(name Env, value any)

	// Env returns value associated with given environment name.
	Env(name Env) (any, bool)

	// Compression returns true if compression is enabled for this process.
	Compression() bool

	// SetCompression enables/disables compression for the messages sent over the network
	SetCompression(enabled bool) error

	// CompressionType returns type of compression
	CompressionType() CompressionType
	// SetCompressionType defines the compression type. Use gen.CompressionTypeZLIB or gen.CompressionTypeLZW. Be default is using gen.CompressionTypeGZIP
	SetCompressionType(ctype CompressionType) error

	// CompressionLevel returns comression level for the process
	CompressionLevel() CompressionLevel

	// SetCompressionLevel defines compression level. Use gen.CompressionBestSize or gen.CompressionBestSpeed. By default is using gen.CompressionDefault
	SetCompressionLevel(level CompressionLevel) error

	// CompressionThreshold returns compression threshold for the process
	CompressionThreshold() int

	// SetCompressionThreshold defines the minimal size for the message that must be compressed
	// Value must be greater than DefaultCompressionThreshold (1024)
	SetCompressionThreshold(threshold int) error

	// SendPriority returns priority for the sending messages
	SendPriority() MessagePriority

	// SetSendPriority defines priority for the sending messages
	SetSendPriority(priority MessagePriority) error

	// SetKeepNetworkOrder enables/disables to keep delivery order over the network. In some cases disabling this options allows improve network performance.
	SetKeepNetworkOrder(order bool) error

	// KeepNetworkOrder returns true if it was enabled, otherwise - false. Enabled by default.
	KeepNetworkOrder() bool

	// SetImportantDelivery enables/disables important flag for sending messages. This flag makes remote node to send confirmation that message was delivered into the process mailbox
	SetImportantDelivery(important bool) error
	// ImportantDelivery returns true if flag ImportantDelivery was set for this process
	ImportantDelivery() bool

	// CreateAlias creates a new alias associated with this process
	CreateAlias() (Alias, error)

	// DeleteAlias deletes the given alias
	DeleteAlias(alias Alias) error

	// Aliases lists of aliases associated with this process
	Aliases() []Alias

	// Events lists of registered events by this process
	Events() []Atom

	// Send sends a message
	Send(to any, message any) error
	SendPID(to PID, message any) error
	SendProcessID(to ProcessID, message any) error
	SendAlias(to Alias, message any) error
	SendWithPriority(to any, message any, priority MessagePriority) error
	SendImportant(to any, message any) error

	// SendAfter starts a timer. When the timer expires, the message sends to the process
	// identified by 'to'. Returns cancel function in order to discard
	// sending a message. CancelFunc returns bool value. If it returns false, than the timer has
	// already expired and the message has been sent.
	SendAfter(to any, message any, after time.Duration) (CancelFunc, error)

	// SendEvent sends event message to the subscribers (to the processes that made link/monitor
	// on this event). Event must be registered with RegisterEvent method.
	SendEvent(name Atom, token Ref, message any) error

	// SendExit sends graceful termination request to the process.
	SendExit(to PID, reason error) error

	// SendExitMeta sends graceful termination request to the meta process.
	SendExitMeta(meta Alias, reason error) error

	SendResponse(to PID, ref Ref, message any) error
	SendResponseError(to PID, ref Ref, err error) error

	// Call makes a sync request
	Call(to any, message any) (any, error)
	CallWithTimeout(to any, message any, timeout int) (any, error)
	CallWithPriority(to any, message any, priority MessagePriority) (any, error)
	CallImportant(to any, message any) (any, error)
	CallPID(to PID, message any, timeout int) (any, error)
	CallProcessID(to ProcessID, message any, timeout int) (any, error)
	CallAlias(to Alias, message any, timeout int) (any, error)

	// Inspect sends inspect request to the process.
	Inspect(target PID, item ...string) (map[string]string, error)
	// Inspect sends inspect request to the meta process.
	InspectMeta(meta Alias, item ...string) (map[string]string, error)

	// RegisterEvent registers a new event. Returns a reference as the token
	// for sending events. Unregistering the event is allowed to the process
	// that registered it. Sending an event can be done in any other process
	// by using the registered event name with the provided token (delegation of
	// event sending feature).
	RegisterEvent(name Atom, options EventOptions) (Ref, error)

	// UnregisterEvent unregisters an event. It can be done by the process owner
	// of this event only.
	UnregisterEvent(name Atom) error

	// links
	Link(target any) error
	Unlink(target any) error

	LinkPID(target PID) error
	UnlinkPID(target PID) error

	LinkProcessID(target ProcessID) error
	UnlinkProcessID(target ProcessID) error

	LinkAlias(target Alias) error
	UnlinkAlias(target Alias) error

	LinkEvent(target Event) ([]MessageEvent, error)
	UnlinkEvent(target Event) error

	LinkNode(target Atom) error
	UnlinkNode(target Atom) error

	// monitors
	Monitor(target any) error
	Demonitor(target any) error

	MonitorPID(pid PID) error
	DemonitorPID(pid PID) error

	MonitorProcessID(process ProcessID) error
	DemonitorProcessID(process ProcessID) error

	MonitorAlias(alias Alias) error
	DemonitorAlias(alias Alias) error

	MonitorEvent(event Event) ([]MessageEvent, error)
	DemonitorEvent(event Event) error

	MonitorNode(node Atom) error
	DemonitorNode(node Atom) error

	// Log returns gen.Log interface
	Log() Log

	// Info returns summary information about this process
	Info() (ProcessInfo, error)

	// MetaInfo returns summary information about given meta process
	MetaInfo(meta Alias) (MetaInfo, error)

	Mailbox() ProcessMailbox
	Behavior() ProcessBehavior
	Forward(to PID, message *MailboxMessage, priority MessagePriority) error
}

Process

type ProcessBehavior

type ProcessBehavior interface {
	ProcessInit(process Process, args ...any) error
	ProcessRun() error
	ProcessTerminate(reason error)
}

ProcessBehavior interface contains methods you should implement to make your own process behavior

type ProcessFactory

type ProcessFactory func() ProcessBehavior

type ProcessFallback

type ProcessFallback struct {
	Enable bool
	Name   Atom
	Tag    string
}

ProcessFallback

type ProcessID

type ProcessID struct {
	Name Atom
	Node Atom
}

ProcessID long notation of registered process {process_name, node_name}

func (ProcessID) MarshalJSON

func (p ProcessID) MarshalJSON() ([]byte, error)

func (ProcessID) String

func (p ProcessID) String() string

String string representaion of ProcessID value

type ProcessInfo

type ProcessInfo struct {
	// PID process ID
	PID PID
	// Name registered associated name with this process
	Name Atom
	// Application application name if this process started under application umbrella
	Application Atom
	// Behavior
	Behavior string
	// MailboxSize
	MailboxSize int64
	// MailboxQueues
	MailboxQueues MailboxQueues
	// MessagesIn total number of messages this process received
	MessagesIn uint64
	// MessagesOut total number of messages this process sent
	MessagesOut uint64
	// RunningTime how long this process was in 'running' state in ns
	RunningTime uint64
	// Compression
	Compression Compression
	// MessagePriority priority for the sending messages
	MessagePriority MessagePriority
	// Uptime of the process in seconds
	Uptime int64
	// State shows current state of the process
	State ProcessState
	// Parent points to the parent process that spawned this process as a child
	Parent PID
	// Leader usually points to the Supervisor or Application process
	Leader PID
	// Fallback
	Fallback ProcessFallback
	// Env process environment. gen.NodeOptions.Security.ExposeEnvInfo must be enabled to reveal this data
	Env map[Env]any
	// Aliases list of the aliases belonging to this process
	Aliases []Alias
	// Events list of the events this process is the owner of
	Events []Atom

	// Metas list of meta processes
	Metas []Alias

	// MonitorsPID list of processes monitored by this process by the PID
	MonitorsPID []PID
	// MonitorsProcessID list of processes monitored by this process by the name
	MonitorsProcessID []ProcessID
	// MonitorsAlias list of aliases monitored by this process
	MonitorsAlias []Alias
	// MonitorsEvent list of events monitored by this process
	MonitorsEvent []Event
	// MonitorsNode list of remote nodes monitored by this process
	MonitorsNode []Atom

	// LinksPID list of the processes this process is linked with
	LinksPID []PID
	// LinksProcessID list of the processes this process is linked with by the name.
	LinksProcessID []ProcessID
	// LinksAlias list of the aliases this process is linked with
	LinksAlias []Alias
	// LinksEvent list of the events this process is linked with
	LinksEvent []Event
	//LinksNode list of the remote nodes this process is linked with
	LinksNode []Atom

	// LogLevel current logging level
	LogLevel LogLevel
	// KeepNetworkOrder
	KeepNetworkOrder bool
	// ImportantDelivery
	ImportantDelivery bool
}

ProcessInfo

type ProcessMailbox

type ProcessMailbox struct {
	Main   lib.QueueMPSC
	System lib.QueueMPSC
	Urgent lib.QueueMPSC
	Log    lib.QueueMPSC
}

type ProcessOptions

type ProcessOptions struct {
	// MailboxSize defines the length of message queue for the process. Default is zero - unlimited
	MailboxSize int64
	// Leader
	Leader PID
	// Env set the process environment variables
	Env map[Env]any

	Compression Compression

	// SendPriority defines the priority of the sending messages.
	// Actor-receiver handles its Mailbox with the next order:
	//  - Urgent
	//  - System
	//  - Main
	// Setting this option to MessagePriorityHigh makes the node deliver messages
	// to the "Mailbox.System" of the receving Process
	// With MessagePriorityMax - makes delivering to the Mailbox.Urgent
	// By default, messages are delivering to the Mailbox.Main.
	SendPriority MessagePriority

	// ImportantDelivery enables important flag for sending messages. This flag makes remote node to send confirmation that message was delivered into the process mailbox
	ImportantDelivery bool

	// Fallback defines the process to where messages will be forwarded
	// if the mailbox is overflowed. The tag value could be used to
	// differentiate the source processes. Forwarded messages are wrapped
	// into the MessageFallback struct with the given tag value.
	// This option is ignored for the unlimited mailbox size
	Fallback ProcessFallback

	// LinkParent creates a link with the parent process on start.
	// It will make this process terminate on the parent process termination.
	// This option is ignored if this process starts by the node.
	LinkParent bool

	// LinkChild makes the node create a link with the spawning process.
	// This feature allows you to link the parent process with the child even
	// being in the init state. This option is ignored if this process starts by the node.
	LinkChild bool

	// LogLevel defines logging level. Default is gen.LogLevelInfo
	LogLevel LogLevel
}

ProcessOptions

type ProcessOptionsExtra

type ProcessOptionsExtra struct {
	ProcessOptions

	ParentPID      PID
	ParentLeader   PID
	ParentEnv      map[Env]any
	ParentLogLevel LogLevel

	Register    Atom
	Application Atom

	Args []any
}

type ProcessShortInfo

type ProcessShortInfo struct {
	// PID process ID
	PID PID
	// Name registered associated name with this process
	Name Atom
	// Application application name if this process started under application umbrella
	Application Atom
	// Behavior
	Behavior string
	// MessagesIn total number of messages this process received
	MessagesIn uint64
	// MessagesOut total number of messages this process sent
	MessagesOut uint64
	// MessagesMailbox total number of messages in mailbox queues
	MessagesMailbox uint64
	// RunningTime how long this process was in 'running' state in ns
	RunningTime uint64
	// Uptime of the process in seconds
	Uptime int64
	// State shows current state of the process
	State ProcessState
	// Parent points to the parent process that spawned this process as a child
	Parent PID
	// Leader usually points to the Supervisor or Application process
	Leader PID
	// LogLevel current logging level
	LogLevel LogLevel
}

ProcessShortInfo

type ProcessState

type ProcessState int32
const (
	ProcessStateInit         ProcessState = 1
	ProcessStateSleep        ProcessState = 2
	ProcessStateRunning      ProcessState = 4
	ProcessStateWaitResponse ProcessState = 8
	ProcessStateTerminated   ProcessState = 16
	ProcessStateZombee       ProcessState = 32
)

func (ProcessState) MarshalJSON

func (p ProcessState) MarshalJSON() ([]byte, error)

func (ProcessState) String

func (p ProcessState) String() string

type ProxyAcceptOptions

type ProxyAcceptOptions struct {
	// Cookie sets cookie for incoming connections
	Cookie string
	// Flags sets options for incoming connections
	Flags NetworkProxyFlags
}

type ProxyRoute

type ProxyRoute struct {
	To    Atom // to
	Proxy Atom // via
}

type ProxyRouteInfo

type ProxyRouteInfo struct {
	Match           string
	Weight          int
	UseResolver     bool
	UseCustomCookie bool
	Flags           NetworkProxyFlags
	MaxHop          int
	Proxy           Atom
}

type ProxyTransitOptions

type ProxyTransitOptions struct {
}

type Ref

type Ref struct {
	Node     Atom
	Creation int64
	ID       [3]uint64
}

Ref

func (Ref) MarshalJSON

func (r Ref) MarshalJSON() ([]byte, error)

func (Ref) String

func (r Ref) String() string

String

type RegisterRoutes

type RegisterRoutes struct {
	Routes            []Route
	ApplicationRoutes []ApplicationRoute
	ProxyRoutes       []ProxyRoute // if Proxy was enabled
}

type Registrar

type Registrar interface {
	// Register invokes on network start
	Register(node NodeRegistrar, routes RegisterRoutes) (StaticRoutes, error)

	// Resolver returns the gen.Resolver interface
	Resolver() Resolver

	// RegisterProxy allows to register this node as a proxy for the given node on the registrar
	// (if the registrar does support this feature)
	RegisterProxy(to Atom) error
	// UnregisterProxy unregisters this node as a proxy to the given node on the registrar
	// (if the registrar does support this feature)
	UnregisterProxy(to Atom) error

	// RegisterApplicationRoute registers the application on the registrar
	// (if the registrar does support this feature).
	RegisterApplicationRoute(route ApplicationRoute) error
	// UnregisterApplication unregisters the given application.
	// (if the registrar does support this feature).
	UnregisterApplicationRoute(name Atom) error

	// Nodes returns a list of the nodes registered on the registrar
	Nodes() ([]Atom, error)
	// Config returns config received from the registrar
	// (if the registrar does support this feature)
	Config(items ...string) (map[string]any, error)
	// ConfigItem returns the value from the config for the given name
	// (if the registrar does support this feature)
	ConfigItem(item string) (any, error)
	// Event returns the event you may want to Link/Monitor
	// (if the registrar does support this feature)
	Event() (Event, error)
	// Info return short information about the registrar
	Info() RegistrarInfo

	// Terminate invokes on network stop.
	Terminate()

	Version() Version
}

Registrar interface

type RegistrarConfig

type RegistrarConfig struct {
	LastUpdate int64 // timestamp
	Config     map[string]any
}

type RegistrarInfo

type RegistrarInfo struct {
	Server                     string
	EmbeddedServer             bool
	SupportRegisterProxy       bool
	SupportRegisterApplication bool
	SupportConfig              bool
	SupportEvent               bool
	Version                    Version
}

type RemoteNode

type RemoteNode interface {
	Name() Atom
	Uptime() int64
	ConnectionUptime() int64
	Version() Version
	Info() RemoteNodeInfo

	Spawn(name Atom, options ProcessOptions, args ...any) (PID, error)
	SpawnRegister(register Atom, name Atom, options ProcessOptions, args ...any) (PID, error)

	// ApplicationStart starts application on the remote node.
	// Starting mode is according to the defined in the gen.ApplicationSpec.Mode
	ApplicationStart(name Atom, options ApplicationOptions) error

	// ApplicationStartTemporary starts application on the remote node in temporary mode
	// overriding the value of gen.ApplicationSpec.Mode
	ApplicationStartTemporary(name Atom, options ApplicationOptions) error

	// ApplicationStartTransient starts application on the remote node in transient mode
	// overriding the value of gen.ApplicationSpec.Mode
	ApplicationStartTransient(name Atom, options ApplicationOptions) error

	// ApplicationStartPermanent starts application on the remote node in permanent mode
	// overriding the value of gen.ApplicationSpec.Mode
	ApplicationStartPermanent(name Atom, options ApplicationOptions) error

	Creation() int64

	Disconnect()
}

type RemoteNodeInfo

type RemoteNodeInfo struct {
	Node             Atom
	Uptime           int64
	ConnectionUptime int64
	Version          Version

	HandshakeVersion Version
	ProtoVersion     Version

	NetworkFlags NetworkFlags

	PoolSize int
	PoolDSN  []string

	MaxMessageSize int
	MessagesIn     uint64
	MessagesOut    uint64

	BytesIn  uint64
	BytesOut uint64

	TransitBytesIn  uint64
	TransitBytesOut uint64
}

type Resolver

type Resolver interface {
	// Resolve resolves the routes for the given node name
	Resolve(node Atom) ([]Route, error)
	// Resolve resolves the proxy routes for the given node name
	ResolveProxy(node Atom) ([]ProxyRoute, error)
	// Resolve resolves the applications routes for the given application.
	// This information allows you to know where the given application is running
	// or loaded.
	ResolveApplication(name Atom) ([]ApplicationRoute, error)
}

Resolver interface

type Route

type Route struct {
	Host             string
	Port             uint16
	TLS              bool
	HandshakeVersion Version
	ProtoVersion     Version
}

type RouteInfo

type RouteInfo struct {
	Match            string
	Weight           int
	UseResolver      bool
	UseCustomCookie  bool
	UseCustomCert    bool
	Flags            NetworkFlags
	HandshakeVersion Version
	ProtoVersion     Version
	Host             string
	Port             uint16
}

type SecurityOptions

type SecurityOptions struct {
	ExposeEnvInfo bool
	// ExposeEnvRemoteSpawn makes remote spawned process inherit env from the parent process/node
	ExposeEnvRemoteSpawn            bool
	ExposeEnvRemoteApplicationStart bool
}

type StaticRoutes

type StaticRoutes struct {
	Routes  map[string]NetworkRoute      // match string => network route
	Proxies map[string]NetworkProxyRoute // match string => proxy route
}

type Version

type Version struct {
	Name    string
	Release string
	Commit  string
	License string
}

Version

func (Version) Str

func (v Version) Str() string

func (Version) String

func (v Version) String() string

Jump to

Keyboard shortcuts

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