operator

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package operator provides the Operator gRPC service implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DrainNotification

type DrainNotification struct {
	InstanceID  string
	Group       string
	Reason      string
	UnhealthyAt time.Time
	DeleteAt    time.Time
}

DrainNotification represents a drain notification event

type InstanceManager

type InstanceManager interface {
	CreateInstance(ctx context.Context, req instances.CreateInstanceRequest) (*instances.CreateInstanceResponse, error)
	DeleteInstance(ctx context.Context, instanceID string) error
	GetInstanceStatus(ctx context.Context, instanceID string) (*instances.InstanceStatus, error)
}

InstanceManager interface for instance operations

type Options

type Options struct {
	ConfigLoader    *serverconfig.Loader
	LocalDB         *localdb.DB
	InstanceManager InstanceManager
	OnGroupChanged  func(tenant, groupKey string)
	OnDrainAcked    func(instanceID string)
	Logger          *slog.Logger

	// Certificate renewal dependencies
	ClusterStorage  storage.Storage
	CACertPEM       []byte
	CAKeyPEM        []byte
	IsClusterLeader func() bool
}

Options contains options for creating an OperatorService

type Service

type Service struct {
	proto.UnimplementedOperatorServiceServer
	// contains filtered or unexported fields
}

Service implements the OperatorService gRPC service

func New

func New(opts Options) (*Service, error)

New creates a new OperatorService

func (*Service) AcknowledgeDrained

func (s *Service) AcknowledgeDrained(ctx context.Context, req *proto.DrainAckRequest) (*emptypb.Empty, error)

func (*Service) CreateInstance

func (*Service) DeleteGroup

func (s *Service) DeleteGroup(ctx context.Context, req *proto.DeleteGroupRequest) (*emptypb.Empty, error)

func (*Service) DeleteInstance

func (*Service) GetConfigStatus

func (s *Service) GetConfigStatus(ctx context.Context, req *emptypb.Empty) (*proto.ConfigStatusResponse, error)

func (*Service) GetInstanceStatus

func (*Service) ListGroups

func (s *Service) ListGroups(ctx context.Context, req *emptypb.Empty) (*proto.ListGroupsResponse, error)

func (*Service) NotifyDrain

func (s *Service) NotifyDrain(notification DrainNotification)

NotifyDrain sends a drain notification to the connected operator (if any)

func (*Service) NotifyError

func (s *Service) NotifyError(event *proto.ErrorEvent)

NotifyError sends an error event to the connected operator (if any)

func (*Service) NotifyGroupEvent

func (s *Service) NotifyGroupEvent(event *proto.GroupEvent)

NotifyGroupEvent sends a group change event to the connected operator (if any)

func (*Service) RefreshConfig

func (s *Service) RefreshConfig(ctx context.Context, req *emptypb.Empty) (*proto.RefreshConfigResponse, error)

func (*Service) RenewCertificate

func (*Service) UpsertGroup

func (s *Service) UpsertGroup(ctx context.Context, req *proto.UpsertGroupRequest) (*proto.GroupStatus, error)

func (*Service) WatchErrors

func (s *Service) WatchErrors(req *emptypb.Empty, stream proto.OperatorService_WatchErrorsServer) error

WatchErrors streams error events (provider errors, config validation failures) to the operator.

func (*Service) WatchGroups

func (s *Service) WatchGroups(req *emptypb.Empty, stream proto.OperatorService_WatchGroupsServer) error

WatchGroups streams group change events to the operator. On connection, sends all current groups as UPSERT events (initial snapshot).

func (*Service) WatchInstances

func (s *Service) WatchInstances(req *emptypb.Empty, stream proto.OperatorService_WatchInstancesServer) error

WatchInstances streams instance events to the operator for drain coordination. On connection, sends all pending drain instances as initial snapshot.

Jump to

Keyboard shortcuts

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