Documentation
¶
Index ¶
- Constants
- Variables
- func ApplicationMemberSpec(opts ApplicationMemberSpecOptions) gen.ApplicationMemberSpec
- func FactorySystemSup(opts ApplicationMemberSpecOptions) gen.ProcessFactory
- func RegisterLauncher(name gen.Atom, launcher Launcher) error
- func UnregisterLauncher(name gen.Atom)
- type AddressBook
- func (book *AddressBook) AddProcess(node gen.Atom, ps ...ProcessInfo) error
- func (book *AddressBook) GetAvailableNodes() *NodeList
- func (book *AddressBook) GetProcessList(node gen.Atom) (list ProcessInfoList, err error)
- func (book *AddressBook) LocateLocal(process gen.Atom) (gen.Atom, bool)
- func (book *AddressBook) PickDirectoryNode(process gen.Atom) gen.Atom
- func (book *AddressBook) PickNode(process gen.Atom) gen.Atom
- func (book *AddressBook) QueryBy(caller gen.Process, option QueryOption) IAddressBookQuery
- func (book *AddressBook) RemoveProcess(node gen.Atom, ps ...ProcessInfo) error
- func (book *AddressBook) SetAvailableNodes(nodes *NodeList) error
- func (book *AddressBook) SetProcess(node gen.Atom, ps ...ProcessInfo) error
- type ApplicationMemberSpecOptions
- type AtomicValue
- type CronJob
- type CronJobScope
- type DaemonIterator
- type DaemonIteratorFactory
- type DaemonProcess
- type IAddressBook
- type IAddressBookQuery
- type ImmutableList
- type Launcher
- type Member
- type MessageAddressBook
- type MessageForwardLocate
- type MessageGetAddressBook
- type MessageLaunchAllDaemon
- type MessageLaunchOneDaemon
- type MessageLocate
- type MessageLocateResult
- type MessageProcessChanged
- type NodeList
- type ProcessInfo
- type ProcessInfoList
- type ProcessVersion
- type QueryOption
- type Spawner
Constants ¶
const ( CronJobLocationUTC = "UTC" CronJobLocationBeijing = "Asia/Shanghai" )
const CronJobProcess = gen.Atom("extensions_cron")
const DaemonMonitorProcess = gen.Atom("extensions_daemon")
const Supervisor = gen.Atom("extensions_sup")
const (
WhereIsProcess = gen.Atom("extensions_whereis")
)
Variables ¶
var ErrNoAvailableNodes = errors.New("no available nodes")
Functions ¶
func ApplicationMemberSpec ¶
func ApplicationMemberSpec(opts ApplicationMemberSpecOptions) gen.ApplicationMemberSpec
func FactorySystemSup ¶
func FactorySystemSup(opts ApplicationMemberSpecOptions) gen.ProcessFactory
func RegisterLauncher ¶
RegisterLauncher registers a launcher with the given name.
func UnregisterLauncher ¶
UnregisterLauncher unregisters a launcher by its name.
Types ¶
type AddressBook ¶
type AddressBook struct {
// contains filtered or unexported fields
}
AddressBook is a registry for all processes running on all nodes in the cluster. It's used to locate processes by their registered names.
func (*AddressBook) AddProcess ¶
func (book *AddressBook) AddProcess(node gen.Atom, ps ...ProcessInfo) error
AddProcess adds a list of processes for the given node.
func (*AddressBook) GetAvailableNodes ¶
func (book *AddressBook) GetAvailableNodes() *NodeList
GetAvailableNodes returns a list of available nodes.
func (*AddressBook) GetProcessList ¶
func (book *AddressBook) GetProcessList(node gen.Atom) (list ProcessInfoList, err error)
GetProcessList returns a list of processes running on the given node.
func (*AddressBook) LocateLocal ¶
LocateLocal returns a process information by its registered name. Note: this only contains local data and should not be used for global process discovery.
func (*AddressBook) PickDirectoryNode ¶
func (book *AddressBook) PickDirectoryNode(process gen.Atom) gen.Atom
PickDirectoryNode returns a directory node name by the given process name using consistent hashing.
func (*AddressBook) PickNode ¶
func (book *AddressBook) PickNode(process gen.Atom) gen.Atom
PickNode returns a node name by the given process name using consistent hashing.
func (*AddressBook) QueryBy ¶
func (book *AddressBook) QueryBy(caller gen.Process, option QueryOption) IAddressBookQuery
Locate returns a process information by its registered name.
func (*AddressBook) RemoveProcess ¶
func (book *AddressBook) RemoveProcess(node gen.Atom, ps ...ProcessInfo) error
RemoveProcess removes a list of processes from the given node.
func (*AddressBook) SetAvailableNodes ¶
func (book *AddressBook) SetAvailableNodes(nodes *NodeList) error
SetAvailableNodes sets a list of available nodes.
func (*AddressBook) SetProcess ¶
func (book *AddressBook) SetProcess(node gen.Atom, ps ...ProcessInfo) error
SetProcess sets a list of processes for the given node. It removes all previously registered processes for this node.
type ApplicationMemberSpecOptions ¶
type ApplicationMemberSpecOptions struct {
AddressBook *AddressBook
CronJobs []CronJob
SyncAddressBookInterval time.Duration
}
type AtomicValue ¶
type AtomicValue[T any] struct { // contains filtered or unexported fields }
func NewAtomicValue ¶
func NewAtomicValue[T any](v ...T) *AtomicValue[T]
func (*AtomicValue[T]) Load ¶
func (self *AtomicValue[T]) Load() T
func (*AtomicValue[T]) Store ¶
func (self *AtomicValue[T]) Store(v T) T
type CronJob ¶
type CronJob struct {
// Name is the unique name of the cron job.
Name gen.Atom
// Spec is the cron expression (e.g., "* * * * *").
Spec string
// Location specifies the timezone for the schedule, default is UTC.
Location string
// TriggerProcess is the name of the process to receive the trigger message.
TriggerProcess gen.Atom
// Scope defines whether the job runs on a single node or across the cluster.
Scope CronJobScope
}
CronJob defines a cron job configuration.
type CronJobScope ¶
type CronJobScope int
const ( CronJobScopeCluster CronJobScope = iota CronJobScopeNode )
type DaemonIterator ¶
type DaemonIterator func() ([]DaemonProcess, bool, error)
type DaemonIteratorFactory ¶
type DaemonIteratorFactory func() DaemonIterator
func SingletonDaemon ¶
func SingletonDaemon(name gen.Atom, args []any) DaemonIteratorFactory
type DaemonProcess ¶
type IAddressBook ¶
type IAddressBook interface {
QueryBy(caller gen.Process, option QueryOption) IAddressBookQuery
PickNode(process gen.Atom) gen.Atom
PickDirectoryNode(process gen.Atom) gen.Atom
GetAvailableNodes() *NodeList
}
IAddressBook defines address book interface
type IAddressBookQuery ¶
type IAddressBookQuery interface {
// Locate performs a global lookup for a process name across the cluster.
// This operation involves network communication and may fail due to timeouts.
Locate(processName gen.Atom) (node gen.Atom, err error)
}
IAddressBookQuery defines the interface for performing distributed queries on the address book.
type ImmutableList ¶
type ImmutableList[T comparable] struct { // contains filtered or unexported fields }
func NewImmutableList ¶
func NewImmutableList[T comparable](list []T) *ImmutableList[T]
The caller must not modify list after passing it to NewImmutableList.
func (*ImmutableList[T]) Exist ¶
func (self *ImmutableList[T]) Exist(elem T) bool
func (*ImmutableList[T]) Get ¶
func (self *ImmutableList[T]) Get(i int) (elem T, ok bool)
func (*ImmutableList[T]) GetAll ¶
func (self *ImmutableList[T]) GetAll() (elems []T)
func (*ImmutableList[T]) Len ¶
func (self *ImmutableList[T]) Len() int
func (*ImmutableList[T]) Range ¶
func (self *ImmutableList[T]) Range(fn func(T) bool)
type Launcher ¶
type Launcher struct {
// Factory is a function that creates a new process.
Factory gen.ProcessFactory
// Option provides options for configuring the process.
Option gen.ProcessOptions
// RecoveryScanner is an optional function that scans for daemons to recover.
RecoveryScanner DaemonIteratorFactory // optional
// contains filtered or unexported fields
}
type Member ¶
type Member string
Member is a wrapper for string to implement consistent.Member interface.
type MessageAddressBook ¶
type MessageAddressBook struct {
Owner gen.PID
Book IAddressBook
}
type MessageForwardLocate ¶
type MessageGetAddressBook ¶
type MessageGetAddressBook struct{}
type MessageLaunchAllDaemon ¶
type MessageLaunchAllDaemon struct{}
type MessageLaunchOneDaemon ¶
type MessageLaunchOneDaemon struct {
Launcher gen.Atom
Process DaemonProcess
}
type MessageLocate ¶
type MessageProcessChanged ¶
type MessageProcessChanged struct {
Node gen.Atom
UpProcess []ProcessInfo
DownProcess []ProcessInfo
Version ProcessVersion
FullSync bool
}
type ProcessInfo ¶
type ProcessInfoList ¶
type ProcessInfoList []ProcessInfo
type ProcessVersion ¶
type ProcessVersion [2]int64
func NewVersion ¶
func NewVersion() ProcessVersion
func (ProcessVersion) Equal ¶
func (v ProcessVersion) Equal(v2 ProcessVersion) bool
func (ProcessVersion) GreaterThan ¶
func (v ProcessVersion) GreaterThan(v2 ProcessVersion) bool
func (ProcessVersion) GreaterThanOrEq ¶
func (v ProcessVersion) GreaterThanOrEq(v2 ProcessVersion) bool
func (ProcessVersion) Incr ¶
func (v ProcessVersion) Incr() ProcessVersion
func (ProcessVersion) String ¶
func (v ProcessVersion) String() string
type QueryOption ¶
type QueryOption struct {
// Timeout specifies the query timeout in seconds.
Timeout int
}
QueryOption defines the options for process lookup.