Documentation ¶
Index ¶
- Constants
- Variables
- func CheckPrerequisites(config *models.NodeConfiguration, noninteractive bool, logger *slog.Logger) error
- func CmdPreflight(opts *nexmodels.Options, nodeopts *nexmodels.NodeOptions, ctx context.Context, ...) error
- func CmdUp(opts *nexmodels.Options, nodeopts *nexmodels.NodeOptions, ctx context.Context, ...) error
- func FullVersion() string
- func LoadNodeConfiguration(configFilepath string) (*models.NodeConfiguration, error)
- func PublishCloudEvent(nc *nats.Conn, namespace string, event cloudevents.Event, log *slog.Logger) error
- func ReadMemoryStats() (*controlapi.MemoryStat, error)
- func Version() string
- type AgentProxy
- type ApiListener
- type HostServices
- type Node
- type NodeProxy
- func (n *NodeProxy) APIListener() *ApiListener
- func (n *NodeProxy) InternalNATS() *server.Server
- func (n *NodeProxy) InternalNATSConn() *nats.Conn
- func (n *NodeProxy) Log() *slog.Logger
- func (n *NodeProxy) NodeConfiguration() *models.NodeConfiguration
- func (n *NodeProxy) Telemetry() *observability.Telemetry
- func (n *NodeProxy) WorkloadManager() *WorkloadManager
- type WorkloadManager
- func (m *WorkloadManager) CacheWorkload(request *controlapi.DeployRequest) (uint64, *string, error)
- func (w *WorkloadManager) DeployWorkload(request *agentapi.DeployRequest) (*string, error)
- func (w *WorkloadManager) LookupWorkload(workloadID string) (*agentapi.DeployRequest, error)
- func (w *WorkloadManager) OnProcessStarted(id string)
- func (w *WorkloadManager) RunningWorkloads() ([]controlapi.MachineSummary, error)
- func (w *WorkloadManager) Start()
- func (w *WorkloadManager) Stop() error
- func (w *WorkloadManager) StopWorkload(id string, undeploy bool) error
- type WorkloadManagerProxy
- func (w *WorkloadManagerProxy) Agents() map[string]*processmanager.ProcessInfo
- func (w *WorkloadManagerProxy) AllAgents() map[string]*processmanager.ProcessInfo
- func (m *WorkloadManagerProxy) InternalNATSConn() *nats.Conn
- func (m *WorkloadManagerProxy) Log() *slog.Logger
- func (m *WorkloadManagerProxy) NodeConfiguration() *models.NodeConfiguration
- func (w *WorkloadManagerProxy) PoolAgents() map[string]*processmanager.ProcessInfo
- func (m *WorkloadManagerProxy) Telemetry() *observability.Telemetry
Constants ¶
const ( EventSubjectPrefix = "$NEX.events" LogSubjectPrefix = "$NEX.logs" WorkloadCacheBucketName = "NEXCACHE" )
Variables ¶
var ( VERSION = "development" COMMIT = "" BUILDDATE = "" )
Functions ¶
func CheckPrerequisites ¶
func CheckPrerequisites(config *models.NodeConfiguration, noninteractive bool, logger *slog.Logger) error
Check prerequisites returns an error if preflight is unsuccessful using the given node configuration.
When noninteractive is true, the preflight checks are run non-interactively, and required prerequisites are automatically installed to configured paths if they are otherwise missing when paired with config.ForceDepInstall.
func CmdPreflight ¶
func FullVersion ¶
func FullVersion() string
func LoadNodeConfiguration ¶
func LoadNodeConfiguration(configFilepath string) (*models.NodeConfiguration, error)
Reads the node configuration from the specified configuration file path
func PublishCloudEvent ¶
func PublishCloudEvent(nc *nats.Conn, namespace string, event cloudevents.Event, log *slog.Logger) error
publish the given $NEX event to an arbitrary namespace using the given NATS connection
func ReadMemoryStats ¶
func ReadMemoryStats() (*controlapi.MemoryStat, error)
This function only works on Linux, but that's okay since nex-node can only run on 64-bit linux
Types ¶
type AgentProxy ¶
type AgentProxy struct {
// contains filtered or unexported fields
}
func NewAgentProxyWith ¶
func NewAgentProxyWith(agent *processmanager.ProcessInfo) *AgentProxy
type ApiListener ¶
type ApiListener struct {
// contains filtered or unexported fields
}
The API listener is the command and control interface for the node server
func NewApiListener ¶
func NewApiListener(log *slog.Logger, mgr *WorkloadManager, node *Node) *ApiListener
func (*ApiListener) Drain ¶
func (api *ApiListener) Drain() error
func (*ApiListener) PublicKey ¶
func (api *ApiListener) PublicKey() string
func (*ApiListener) PublicXKey ¶
func (api *ApiListener) PublicXKey() string
func (*ApiListener) Start ¶
func (api *ApiListener) Start() error
type HostServices ¶
type HostServices struct {
// contains filtered or unexported fields
}
Host services server implements select functionality which is exposed to workloads by way of the agent which makes RPC calls via the internal NATS connection
func NewHostServices ¶
func NewHostServices( mgr *WorkloadManager, ncint *nats.Conn, ncHostServices *nats.Conn, config *models.HostServicesConfig, log *slog.Logger, ) *HostServices
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Nex node process
func (*Node) EnterLameDuck ¶
func (*Node) IsLameDuck ¶
type NodeProxy ¶
type NodeProxy struct {
// contains filtered or unexported fields
}
Use this proxy object with extreme care, as it exposes the private/internal bits of a node instance to callers. It was created only as a way to make writing specs work and should not be used for any other purpose!
func NewNodeProxyWith ¶
func (*NodeProxy) APIListener ¶
func (n *NodeProxy) APIListener() *ApiListener
func (*NodeProxy) InternalNATS ¶
func (*NodeProxy) InternalNATSConn ¶
func (n *NodeProxy) InternalNATSConn() *nats.Conn
func (*NodeProxy) NodeConfiguration ¶
func (n *NodeProxy) NodeConfiguration() *models.NodeConfiguration
func (*NodeProxy) Telemetry ¶
func (n *NodeProxy) Telemetry() *observability.Telemetry
func (*NodeProxy) WorkloadManager ¶
func (n *NodeProxy) WorkloadManager() *WorkloadManager
type WorkloadManager ¶
type WorkloadManager struct {
// contains filtered or unexported fields
}
The workload manager provides the high level strategy for the Nex node's workload management. It is responsible for using a process manager interface to manage processes and maintaining agent clients that communicate with those processes. The workload manager does not know how the agent processes are created, only how to communicate with them via the internal NATS server
func NewWorkloadManager ¶
func NewWorkloadManager( ctx context.Context, cancel context.CancelFunc, nodeKeypair nkeys.KeyPair, publicKey string, nc, ncint, ncHostServices *nats.Conn, config *models.NodeConfiguration, log *slog.Logger, telemetry *observability.Telemetry, ) (*WorkloadManager, error)
Initialize a new workload manager instance to manage and communicate with agents
func (*WorkloadManager) CacheWorkload ¶
func (m *WorkloadManager) CacheWorkload(request *controlapi.DeployRequest) (uint64, *string, error)
func (*WorkloadManager) DeployWorkload ¶
func (w *WorkloadManager) DeployWorkload(request *agentapi.DeployRequest) (*string, error)
Deploy a workload as specified by the given deploy request to an available agent in the configured pool
func (*WorkloadManager) LookupWorkload ¶
func (w *WorkloadManager) LookupWorkload(workloadID string) (*agentapi.DeployRequest, error)
Locates a given workload by its workload ID and returns the deployment request associated with it Note that this means "pending" workloads are not considered by lookups
func (*WorkloadManager) OnProcessStarted ¶
func (w *WorkloadManager) OnProcessStarted(id string)
Called by the agent process manager when an agent has been warmed and is ready to receive workload deployment instructions
func (*WorkloadManager) RunningWorkloads ¶
func (w *WorkloadManager) RunningWorkloads() ([]controlapi.MachineSummary, error)
Retrieve a list of deployed, running workloads
func (*WorkloadManager) Start ¶
func (w *WorkloadManager) Start()
Start the workload manager, which in turn starts the configured agent process manager
func (*WorkloadManager) Stop ¶
func (w *WorkloadManager) Stop() error
Stop the workload manager, which will in turn stop all managed agents and attempt to clean up all applicable resources.
func (*WorkloadManager) StopWorkload ¶
func (w *WorkloadManager) StopWorkload(id string, undeploy bool) error
Stop a workload, optionally attempting a graceful undeploy prior to termination
type WorkloadManagerProxy ¶
type WorkloadManagerProxy struct {
// contains filtered or unexported fields
}
func NewWorkloadManagerProxyWith ¶
func NewWorkloadManagerProxyWith(manager *WorkloadManager) *WorkloadManagerProxy
func (*WorkloadManagerProxy) Agents ¶
func (w *WorkloadManagerProxy) Agents() map[string]*processmanager.ProcessInfo
func (*WorkloadManagerProxy) AllAgents ¶
func (w *WorkloadManagerProxy) AllAgents() map[string]*processmanager.ProcessInfo
func (*WorkloadManagerProxy) InternalNATSConn ¶
func (m *WorkloadManagerProxy) InternalNATSConn() *nats.Conn
func (*WorkloadManagerProxy) Log ¶
func (m *WorkloadManagerProxy) Log() *slog.Logger
func (*WorkloadManagerProxy) NodeConfiguration ¶
func (m *WorkloadManagerProxy) NodeConfiguration() *models.NodeConfiguration
func (*WorkloadManagerProxy) PoolAgents ¶
func (w *WorkloadManagerProxy) PoolAgents() map[string]*processmanager.ProcessInfo
func (*WorkloadManagerProxy) Telemetry ¶
func (m *WorkloadManagerProxy) Telemetry() *observability.Telemetry