Documentation ¶
Index ¶
- Constants
- Variables
- func NodeUtilizationIndex(s *Status) float64
- func ScoreNode(d *Node)
- type AddCapturerRequest
- type Capturer
- type ClientGenerator
- type Ctl
- type GRPCNodeClient
- func (c *GRPCNodeClient) AddCapturer(ctx context.Context, request *AddCapturerRequest) error
- func (c *GRPCNodeClient) Connect() error
- func (c *GRPCNodeClient) LoadCategories(ctx context.Context, request *LoadCategoriesRequest) error
- func (c *GRPCNodeClient) NextResult() (*Result, error)
- func (c *GRPCNodeClient) NextStatus() (*Status, error)
- func (c *GRPCNodeClient) RemoveCapturer(ctx context.Context, request *RemoveCapturerRequest) error
- func (c *GRPCNodeClient) Shutdown() error
- type HeapNodePriorityQueue
- func (h *HeapNodePriorityQueue) Len() int
- func (h *HeapNodePriorityQueue) Less(i, j int) bool
- func (h *HeapNodePriorityQueue) Next() *Node
- func (h *HeapNodePriorityQueue) Pop() interface{}
- func (h *HeapNodePriorityQueue) Push(x interface{})
- func (h *HeapNodePriorityQueue) Remove(uuid string) error
- func (h *HeapNodePriorityQueue) Swap(i, j int)
- func (h *HeapNodePriorityQueue) Upsert(node *Node)
- type LoadAverage
- type LoadCategoriesRequest
- type Memory
- type Network
- type Node
- type NodeClient
- type NodeHandler
- type NodePriorityQueue
- type NodeRegistry
- type RemoveCapturerRequest
- type Result
- type Server
- type Status
- type System
Constants ¶
const ( MaxNodeStatusQueueSize = 50 MaxNodeResultQueueSize = 50 StreamConnectTimeout = time.Second )
Variables ¶
var (
ErrNotAvailableNode = errors.New("ctl: cannot find suitable node")
)
Functions ¶
func NodeUtilizationIndex ¶
NodeUtilizationIndex calculates a utilization index based on the internal consumption of system resources in a node. The higher the value the more busy will be the node, so less eligible. This function will return an infinite positive value in case of any resource exceeds the limit threshold, indicating that the node should not be chosen. We cannot assume that this function will always return a percentage. Its just an index, the lower, the best.
The current implementation is a simplistic one (see comments) and works on a best effort.
func ScoreNode ¶
func ScoreNode(d *Node)
ScoreNode calculates a general score for the Node passed and sets the value in the Node struct. This function tends to include all the available calculations in order to nurture a priority queue. The more the score the more eligible will be the node. Negative scoring is possible.
Types ¶
type AddCapturerRequest ¶
type ClientGenerator ¶
type Ctl ¶
type Ctl struct {
// contains filtered or unexported fields
}
func (*Ctl) LoadCategories ¶
type GRPCNodeClient ¶
type GRPCNodeClient struct {
// contains filtered or unexported fields
}
func NewGRPCNodeClient ¶
func (*GRPCNodeClient) AddCapturer ¶
func (c *GRPCNodeClient) AddCapturer(ctx context.Context, request *AddCapturerRequest) error
func (*GRPCNodeClient) Connect ¶
func (c *GRPCNodeClient) Connect() error
func (*GRPCNodeClient) LoadCategories ¶
func (c *GRPCNodeClient) LoadCategories(ctx context.Context, request *LoadCategoriesRequest) error
func (*GRPCNodeClient) NextResult ¶
func (c *GRPCNodeClient) NextResult() (*Result, error)
func (*GRPCNodeClient) NextStatus ¶
func (c *GRPCNodeClient) NextStatus() (*Status, error)
func (*GRPCNodeClient) RemoveCapturer ¶
func (c *GRPCNodeClient) RemoveCapturer(ctx context.Context, request *RemoveCapturerRequest) error
func (*GRPCNodeClient) Shutdown ¶
func (c *GRPCNodeClient) Shutdown() error
type HeapNodePriorityQueue ¶
type HeapNodePriorityQueue struct {
// contains filtered or unexported fields
}
HeapNodePriorityQueue is an implementation of NodePriorityQueue based on a heap. This necessary implements heap.Interface, as we are using the out of the box heap of the std lib. Such methods should be used only internally by the std lib.
func NewHeapNodePriorityQueue ¶
func NewHeapNodePriorityQueue() *HeapNodePriorityQueue
func (*HeapNodePriorityQueue) Len ¶
func (h *HeapNodePriorityQueue) Len() int
func (*HeapNodePriorityQueue) Less ¶
func (h *HeapNodePriorityQueue) Less(i, j int) bool
func (*HeapNodePriorityQueue) Next ¶
func (h *HeapNodePriorityQueue) Next() *Node
func (*HeapNodePriorityQueue) Pop ¶
func (h *HeapNodePriorityQueue) Pop() interface{}
func (*HeapNodePriorityQueue) Push ¶
func (h *HeapNodePriorityQueue) Push(x interface{})
func (*HeapNodePriorityQueue) Remove ¶
func (h *HeapNodePriorityQueue) Remove(uuid string) error
func (*HeapNodePriorityQueue) Swap ¶
func (h *HeapNodePriorityQueue) Swap(i, j int)
func (*HeapNodePriorityQueue) Upsert ¶
func (h *HeapNodePriorityQueue) Upsert(node *Node)
type LoadAverage ¶
type LoadCategoriesRequest ¶
type NodeClient ¶
type NodeClient interface { Connect() error LoadCategories(ctx context.Context, r *LoadCategoriesRequest) error AddCapturer(ctx context.Context, r *AddCapturerRequest) error RemoveCapturer(ctx context.Context, r *RemoveCapturerRequest) error NextStatus() (*Status, error) NextResult() (*Result, error) Shutdown() error }
type NodeHandler ¶
type NodeHandler struct {
// contains filtered or unexported fields
}
func NewNodeHandler ¶
func NewNodeHandler(node *Node, client NodeClient, logger *logrus.Logger) *NodeHandler
func (*NodeHandler) LoadCategories ¶
func (*NodeHandler) Shutdown ¶
func (ds *NodeHandler) Shutdown() error
func (*NodeHandler) Start ¶
func (ds *NodeHandler) Start() error
type NodePriorityQueue ¶
type NodePriorityQueue interface { // Upsert will add the *Node passed as argument to the queue. // If the element already exists it will replace it. Upsert(*Node) Len() int Remove(string) error // Next must return the next most suitable *Node for doing some task. // When the queue is empty, nil should be returned. Next() *Node }
NodePriorityQueue defines the interfaces needed for interacting with the scheduler. Multiple implementations based on different criteria are expected.
type NodeRegistry ¶
type NodeRegistry struct {
// contains filtered or unexported fields
}
func NewNodeRegistry ¶
func NewNodeRegistry(nodeQueue NodePriorityQueue, logger *logrus.Logger) *NodeRegistry
func (*NodeRegistry) Add ¶
func (r *NodeRegistry) Add(s *NodeHandler)
func (*NodeRegistry) Find ¶
func (r *NodeRegistry) Find(_ string) (NodeClient, error)
func (*NodeRegistry) LoadCategories ¶
func (*NodeRegistry) ShutdownAll ¶
func (r *NodeRegistry) ShutdownAll(ctx context.Context) error
type RemoveCapturerRequest ¶
type RemoveCapturerRequest struct {
UUID string
}