github.com/filecoin-project/bacalhau@v0.3.23-0.20230228154132-45c989550ace/pkg/model/v1beta1/nodeinfo.go (about)

     1  package v1beta1
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/libp2p/go-libp2p/core/peer"
     7  )
     8  
     9  type NodeType int
    10  
    11  const (
    12  	nodeTypeUnknown NodeType = iota
    13  	NodeTypeCompute
    14  )
    15  
    16  type NodeInfoProvider interface {
    17  	GetNodeInfo(ctx context.Context) NodeInfo
    18  }
    19  
    20  type ComputeNodeInfoProvider interface {
    21  	GetComputeInfo(ctx context.Context) ComputeNodeInfo
    22  }
    23  
    24  type NodeInfo struct {
    25  	PeerInfo        peer.AddrInfo     `json:"PeerInfo"`
    26  	NodeType        NodeType          `json:"NodeType"`
    27  	Labels          map[string]string `json:"Labels"`
    28  	ComputeNodeInfo ComputeNodeInfo   `json:"ComputeNodeInfo"`
    29  }
    30  
    31  // IsComputeNode returns true if the node is a compute node
    32  func (n NodeInfo) IsComputeNode() bool {
    33  	return n.NodeType == NodeTypeCompute
    34  }
    35  
    36  type ComputeNodeInfo struct {
    37  	ExecutionEngines   []Engine          `json:"ExecutionEngines"`
    38  	MaxCapacity        ResourceUsageData `json:"MaxCapacity"`
    39  	AvailableCapacity  ResourceUsageData `json:"AvailableCapacity"`
    40  	MaxJobRequirements ResourceUsageData `json:"MaxJobRequirements"`
    41  	RunningExecutions  int               `json:"RunningExecutions"`
    42  	EnqueuedExecutions int               `json:"EnqueuedExecutions"`
    43  }