Help us shape the future of Go! Take the 2026 Go Developer Survey

agent

package
v0.0.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 25, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package agent provides gRPC client for communicating with node agents.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateDeployRequest

func ValidateDeployRequest(req *DeployRequest) error

ValidateDeployRequest checks that a DeployRequest has all required fields. This is used for property testing to ensure deployment commands are complete.

Types

type Client

type Client interface {
	// Deploy instructs the agent to deploy an artifact on the node.
	Deploy(ctx context.Context, nodeID string, req *DeployRequest) error
	// Stop instructs the agent to stop a running deployment.
	Stop(ctx context.Context, nodeID string, deploymentID string) error
	// GetStatus retrieves the current status of a deployment.
	GetStatus(ctx context.Context, nodeID string, deploymentID string) (*DeploymentStatus, error)
	// StreamLogs streams logs from a deployment in real-time.
	StreamLogs(ctx context.Context, nodeID string, deploymentID string) (<-chan *models.LogEntry, error)
	// Close closes all connections.
	Close() error
}

Client defines the interface for communicating with node agents.

type ClientConfig

type ClientConfig struct {
	// TLSConfig for secure connections. If nil, insecure connections are used.
	TLSConfig *tls.Config
	// DialTimeout is the timeout for establishing connections.
	DialTimeout time.Duration
	// RequestTimeout is the default timeout for RPC calls.
	RequestTimeout time.Duration
	// MaxRetries is the maximum number of retry attempts.
	MaxRetries int
	// InitialBackoff is the initial backoff duration for retries.
	InitialBackoff time.Duration
	// MaxBackoff is the maximum backoff duration for retries.
	MaxBackoff time.Duration
	// BackoffMultiplier is the multiplier for exponential backoff.
	BackoffMultiplier float64
}

ClientConfig holds configuration for the gRPC client.

func DefaultClientConfig

func DefaultClientConfig() *ClientConfig

DefaultClientConfig returns a ClientConfig with sensible defaults.

type DeployRequest

type DeployRequest struct {
	DeploymentID string
	Artifact     string
	BuildType    models.BuildType
	Config       *models.RuntimeConfig
	Secrets      map[string]string
}

DeployRequest contains all information needed to deploy an artifact.

type DeploymentStatus

type DeploymentStatus struct {
	DeploymentID string
	Status       models.DeploymentStatus
	Message      string
	StartedAt    *time.Time
	UpdatedAt    time.Time
}

DeploymentStatus contains the current status of a deployment.

type GRPCClient

type GRPCClient struct {
	// contains filtered or unexported fields
}

GRPCClient implements the Client interface using gRPC.

func NewGRPCClient

func NewGRPCClient(resolver NodeResolver, config *ClientConfig, logger *slog.Logger) *GRPCClient

NewGRPCClient creates a new gRPC client for agent communication.

func (*GRPCClient) Close

func (c *GRPCClient) Close() error

Close closes all connections.

func (*GRPCClient) Deploy

func (c *GRPCClient) Deploy(ctx context.Context, nodeID string, req *DeployRequest) error

Deploy instructs the agent to deploy an artifact on the node.

func (*GRPCClient) GetStatus

func (c *GRPCClient) GetStatus(ctx context.Context, nodeID string, deploymentID string) (*DeploymentStatus, error)

GetStatus retrieves the current status of a deployment.

func (*GRPCClient) RemoveConnection

func (c *GRPCClient) RemoveConnection(nodeID string)

RemoveConnection removes a connection from the pool (e.g., when a node becomes unhealthy).

func (*GRPCClient) Stop

func (c *GRPCClient) Stop(ctx context.Context, nodeID string, deploymentID string) error

Stop instructs the agent to stop a running deployment.

func (*GRPCClient) StreamLogs

func (c *GRPCClient) StreamLogs(ctx context.Context, nodeID string, deploymentID string) (<-chan *models.LogEntry, error)

StreamLogs streams logs from a deployment in real-time.

type NodeResolver

type NodeResolver interface {
	// GetNodeAddress returns the gRPC address for a node.
	GetNodeAddress(ctx context.Context, nodeID string) (string, error)
}

NodeResolver resolves node IDs to their gRPC addresses.

type StoreNodeResolver

type StoreNodeResolver struct {
	// contains filtered or unexported fields
}

StoreNodeResolver implements NodeResolver using the store.

func NewStoreNodeResolver

func NewStoreNodeResolver(store interface {
	Nodes() interface {
		Get(ctx context.Context, id string) (*models.Node, error)
	}
}) *StoreNodeResolver

NewStoreNodeResolver creates a NodeResolver that uses the store to look up nodes.

func (*StoreNodeResolver) GetNodeAddress

func (r *StoreNodeResolver) GetNodeAddress(ctx context.Context, nodeID string) (string, error)

GetNodeAddress returns the gRPC address for a node.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL