Documentation
¶
Index ¶
- Variables
- func Init()
- func InitController()
- func RemoteCallback(url string, body serializer.UploadCallback) error
- type Controller
- type MasterInfo
- type MasterNode
- func (node *MasterNode) DBModel() *model.Node
- func (node *MasterNode) GetAria2Instance() common.Aria2
- func (node *MasterNode) ID() uint
- func (node *MasterNode) Init(nodeModel *model.Node)
- func (node *MasterNode) IsActive() bool
- func (node *MasterNode) IsFeatureEnabled(feature string) bool
- func (node *MasterNode) IsMater() bool
- func (node *MasterNode) Kill()
- func (node *MasterNode) MasterAuthInstance() auth.Auth
- func (node *MasterNode) Ping(req *serializer.NodePingReq) (*serializer.NodePingResp, error)
- func (node *MasterNode) SlaveAuthInstance() auth.Auth
- func (node *MasterNode) SubscribeStatusChange(callback func(isActive bool, id uint))
- type Node
- type NodePool
- type Pool
- type SlaveNode
- func (node *SlaveNode) DBModel() *model.Node
- func (node *SlaveNode) GetAria2Instance() common.Aria2
- func (node *SlaveNode) ID() uint
- func (node *SlaveNode) Init(nodeModel *model.Node)
- func (node *SlaveNode) IsActive() bool
- func (node *SlaveNode) IsFeatureEnabled(feature string) bool
- func (node *SlaveNode) IsMater() bool
- func (node *SlaveNode) Kill()
- func (node *SlaveNode) MasterAuthInstance() auth.Auth
- func (node *SlaveNode) Ping(req *serializer.NodePingReq) (*serializer.NodePingResp, error)
- func (node *SlaveNode) SlaveAuthInstance() auth.Auth
- func (node *SlaveNode) StartPingLoop()
- func (node *SlaveNode) SubscribeStatusChange(callback func(bool, uint))
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFeatureNotExist = errors.New("No nodes in nodepool match the feature specificed") ErrIlegalPath = errors.New("path out of boundary of setting temp folder") ErrMasterNotFound = serializer.NewError(serializer.CodeMasterNotFound, "未知的主机节点", nil) )
Functions ¶
func InitController ¶
func InitController()
func RemoteCallback ¶
func RemoteCallback(url string, body serializer.UploadCallback) error
RemoteCallback 发送远程存储策略上传回调请求
Types ¶
type Controller ¶
type Controller interface {
// Handle heartbeat sent from master
HandleHeartBeat(*serializer.NodePingReq) (serializer.NodePingResp, error)
// Get Aria2 Instance by master node ID
GetAria2Instance(string) (common.Aria2, error)
// Send event change message to master node
SendNotification(string, string, mq.Message) error
// Submit async task into task pool
SubmitTask(string, interface{}, string, func(interface{})) error
// Get master node info
GetMasterInfo(string) (*MasterInfo, error)
// Get master OneDrive policy credential
GetOneDriveToken(string, uint) (string, error)
}
Controller controls communications between master and slave
var DefaultController Controller
type MasterInfo ¶
type MasterInfo struct {
ID string
TTL int
URL *url.URL
// used to invoke aria2 rpc calls
Instance Node
Client request.Client
// contains filtered or unexported fields
}
info of master node
type MasterNode ¶
func (*MasterNode) DBModel ¶
func (node *MasterNode) DBModel() *model.Node
func (*MasterNode) GetAria2Instance ¶
func (node *MasterNode) GetAria2Instance() common.Aria2
GetAria2Instance 获取主机Aria2实例
func (*MasterNode) ID ¶
func (node *MasterNode) ID() uint
func (*MasterNode) IsFeatureEnabled ¶
func (node *MasterNode) IsFeatureEnabled(feature string) bool
IsFeatureEnabled 查询节点的某项功能是否启用
func (*MasterNode) IsMater ¶
func (node *MasterNode) IsMater() bool
func (*MasterNode) MasterAuthInstance ¶
func (node *MasterNode) MasterAuthInstance() auth.Auth
func (*MasterNode) Ping ¶
func (node *MasterNode) Ping(req *serializer.NodePingReq) (*serializer.NodePingResp, error)
func (*MasterNode) SlaveAuthInstance ¶
func (node *MasterNode) SlaveAuthInstance() auth.Auth
func (*MasterNode) SubscribeStatusChange ¶
func (node *MasterNode) SubscribeStatusChange(callback func(isActive bool, id uint))
SubscribeStatusChange 订阅节点状态更改
type Node ¶
type Node interface {
// Init a node from database model
Init(node *model.Node)
// Check if given feature is enabled
IsFeatureEnabled(feature string) bool
// Subscribe node status change to a callback function
SubscribeStatusChange(callback func(isActive bool, id uint))
// Ping the node
Ping(req *serializer.NodePingReq) (*serializer.NodePingResp, error)
// Returns if the node is active
IsActive() bool
// Get instances for aria2 calls
GetAria2Instance() common.Aria2
// Returns unique id of this node
ID() uint
// Kill node and recycle resources
Kill()
// Returns if current node is master node
IsMater() bool
// Get auth instance used to check RPC call from slave to master
MasterAuthInstance() auth.Auth
// Get auth instance used to check RPC call from master to slave
SlaveAuthInstance() auth.Auth
// Get node DB model
DBModel() *model.Node
}
func NewNodeFromDBModel ¶
Create new node from DB model
type NodePool ¶
type NodePool struct {
// contains filtered or unexported fields
}
NodePool 通用节点池
var Default *NodePool
func (*NodePool) BalanceNodeByFeature ¶
BalanceNodeByFeature 根据 feature 和 LoadBalancer 取出节点
func (*NodePool) GetNodeByID ¶
type Pool ¶
type Pool interface {
// Returns active node selected by given feature and load balancer
BalanceNodeByFeature(feature string, lb balancer.Balancer) (error, Node)
// Returns node by ID
GetNodeByID(id uint) Node
// Add given node into pool. If node existed, refresh node.
Add(node *model.Node)
// Delete and kill node from pool by given node id
Delete(id uint)
}
Pool 节点池
type SlaveNode ¶
func (*SlaveNode) GetAria2Instance ¶
GetAria2Instance 获取从机Aria2实例
func (*SlaveNode) IsFeatureEnabled ¶
IsFeatureEnabled 查询节点的某项功能是否启用
func (*SlaveNode) MasterAuthInstance ¶
func (*SlaveNode) Ping ¶
func (node *SlaveNode) Ping(req *serializer.NodePingReq) (*serializer.NodePingResp, error)
Ping 从机节点,返回从机负载
func (*SlaveNode) SlaveAuthInstance ¶
func (*SlaveNode) StartPingLoop ¶
func (node *SlaveNode) StartPingLoop()
func (*SlaveNode) SubscribeStatusChange ¶
SubscribeStatusChange 订阅节点状态更改
Click to show internal directories.
Click to hide internal directories.