coordinator

package
v1.26.6 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: GPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingTLSConfig = fmt.Errorf("TLS enabled but no certificates provided")
)

Errors

Functions

This section is empty.

Types

type Client

type Client interface {
	execution.Dispatcher

	// Dispatch sends a task to the coordinator
	Dispatch(ctx context.Context, task *coordinatorv1.Task) error

	// Poll retrieves a task from the coordinator.
	Poll(ctx context.Context, policy backoff.RetryPolicy, req *coordinatorv1.PollRequest) (*coordinatorv1.Task, error)

	// GetWorkers retrieves the list of workers from the coordinator
	GetWorkers(ctx context.Context) ([]*coordinatorv1.WorkerInfo, error)

	// Heartbeat sends a heartbeat to the coordinator
	Heartbeat(ctx context.Context, req *coordinatorv1.HeartbeatRequest) error

	// Metrics returns the metrics for the coordinator client
	Metrics() Metrics
}

Client abstracts handling communication with the coordinator service using service registry and gRPC.

func New

func New(registry execution.ServiceRegistry, config *Config) Client

New creates a new coordinator client with the given configuration

type Config

type Config struct {
	// TLS configuration
	Insecure      bool   // Use insecure connection (default: true)
	CertFile      string // Client certificate
	KeyFile       string // Client key
	CAFile        string // CA certificate
	SkipTLSVerify bool   // Skip server certificate verification

	// Timeouts
	DialTimeout    time.Duration // Connection timeout (default: 10s)
	RequestTimeout time.Duration // Per-request timeout (default: 5m)

	// Retry configuration
	MaxRetries    int           // Max dispatch retries (default: 3)
	RetryInterval time.Duration // Base retry interval (default: 1s)
}

Config holds configuration for the coordinator client

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns a Config with default values

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid

type Handler

type Handler struct {
	coordinatorv1.UnimplementedCoordinatorServiceServer
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler() *Handler

func (*Handler) Dispatch

Dispatch tries to send a task to a waiting poller It fails if no pollers are available or no workers match the selector

func (*Handler) GetWorkers

GetWorkers returns the list of currently connected workers

func (*Handler) Heartbeat

Heartbeat receives periodic status updates from workers

func (*Handler) Poll

Poll implements long polling - workers wait until a task is available

type Metrics

type Metrics struct {
	FailCount        int   // Total number of failures
	IsConnected      bool  // Whether the client is currently connected
	ConsecutiveFails int   // Number of consecutive failures
	LastError        error // Last error encountered
}

Metrics defines the metrics for the coordinator client

type Service

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

func NewService

func NewService(
	server *grpc.Server,
	handler *Handler,
	grpcListener net.Listener,
	healthServer *health.Server,
	registry execution.ServiceRegistry,
	instanceID string,
	configuredHost string,
) *Service

func (*Service) Start

func (srv *Service) Start(ctx context.Context) error

func (*Service) Stop

func (srv *Service) Stop(ctx context.Context) error

Jump to

Keyboard shortcuts

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