service

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: 14 Imported by: 0

Documentation

Overview

Package service provides the core business logic for nstance-admin operations. Both CLI commands and HTTP handlers use these services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigRefreshRequest

type ConfigRefreshRequest struct {
	Shard     string
	AllShards bool
}

ConfigRefreshRequest contains parameters for refreshing config.

type ConfigRefreshResponse

type ConfigRefreshResponse struct {
	Shards []ShardRefreshResult
}

ConfigRefreshResponse contains results for one or more shards.

type ConfigService

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

ConfigService manages configuration operations on Nstance servers.

func NewConfigService

func NewConfigService(connector *Connector) *ConfigService

NewConfigService creates a new ConfigService.

func (*ConfigService) Refresh

Refresh triggers configuration refresh on one or more shards.

func (*ConfigService) Status

Status retrieves configuration status from one or more shards.

type ConfigStatusRequest

type ConfigStatusRequest struct {
	Shard     string
	AllShards bool
}

ConfigStatusRequest contains parameters for checking config status.

type ConfigStatusResponse

type ConfigStatusResponse struct {
	Shards []ShardStatus
}

ConfigStatusResponse contains status for one or more shards.

type Connection

type Connection struct {
	Address string
	ShardID string
	Client  proto.OperatorServiceClient
	// contains filtered or unexported fields
}

Connection represents an active gRPC connection to a shard server.

func (*Connection) Close

func (c *Connection) Close() error

Close closes the gRPC connection.

type Connector

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

Connector manages gRPC connections to nstance-servers.

func NewConnector

func NewConnector(servers []ShardServer, tlsConfig *tls.Config, timeout time.Duration, logger *slog.Logger) *Connector

NewConnector creates a new Connector.

func (*Connector) Close

func (c *Connector) Close()

Close closes all connections.

func (*Connector) ConnectAll

func (c *Connector) ConnectAll(ctx context.Context) ([]*Connection, error)

ConnectAll connects to all servers in the list.

func (*Connector) ConnectShard

func (c *Connector) ConnectShard(ctx context.Context, shardID string) (*Connection, error)

ConnectShard connects to a specific shard by ID.

func (*Connector) GetConnection

func (c *Connector) GetConnection(ctx context.Context) (*grpc.ClientConn, string, error)

GetConnection returns a gRPC connection to any available shard. It tries existing connections first, then attempts to connect to servers.

func (*Connector) Servers

func (c *Connector) Servers() []ShardServer

Servers returns the list of configured servers.

type GroupCreateRequest

type GroupCreateRequest struct {
	Shard        string
	AllShards    bool
	Group        string
	Template     string
	Size         int32
	InstanceType string
	SubnetPool   string
	Vars         map[string]string
}

GroupCreateRequest contains parameters for creating a group.

type GroupCreateResponse

type GroupCreateResponse struct {
	Results []GroupCreateResult
}

GroupCreateResponse contains results for one or more shards.

type GroupCreateResult

type GroupCreateResult struct {
	Shard string
	Group string
	Size  int32
	Error error
}

GroupCreateResult represents the result of creating a group on a shard.

type GroupDeleteRequest

type GroupDeleteRequest struct {
	Shard     string
	AllShards bool
	Group     string
}

GroupDeleteRequest contains parameters for deleting a group.

type GroupDeleteResponse

type GroupDeleteResponse struct {
	Results []GroupDeleteResult
}

GroupDeleteResponse contains results for one or more shards.

type GroupDeleteResult

type GroupDeleteResult struct {
	Shard string
	Group string
	Error error
}

GroupDeleteResult represents the result of deleting a group on a shard.

type GroupListRequest

type GroupListRequest struct {
	Shard     string
	AllShards bool
}

GroupListRequest contains parameters for listing groups.

type GroupListResponse

type GroupListResponse struct {
	Results []GroupListResult
}

GroupListResponse contains results for one or more shards.

type GroupListResult

type GroupListResult struct {
	Shard        string
	Key          string
	Size         int32
	Template     string
	InstanceType string
	IsStatic     bool
	Error        error
}

GroupListResult represents a group from a shard.

type GroupScaleRequest

type GroupScaleRequest struct {
	Shard     string
	AllShards bool
	Group     string
	Size      int32
}

GroupScaleRequest contains parameters for scaling a group.

type GroupScaleResponse

type GroupScaleResponse struct {
	Results []GroupScaleResult
}

GroupScaleResponse contains results for one or more shards.

type GroupScaleResult

type GroupScaleResult struct {
	Shard string
	Group string
	Size  int32
	Error error
}

GroupScaleResult represents the result of scaling a group.

type GroupService

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

GroupService manages group operations on Nstance servers.

func NewGroupService

func NewGroupService(connector *Connector) *GroupService

NewGroupService creates a new GroupService.

func (*GroupService) Create

Create creates a new dynamic group on one or more shards.

func (*GroupService) Delete

Delete removes a dynamic group from one or more shards.

func (*GroupService) List

List returns all groups from one or more shards.

func (*GroupService) Scale

Scale updates the size of a group on one or more shards.

func (*GroupService) Status

Status returns detailed status of a specific group from one or more shards.

type GroupStatusRequest

type GroupStatusRequest struct {
	Shard     string
	AllShards bool
	Group     string
}

GroupStatusRequest contains parameters for getting group status.

type GroupStatusResponse

type GroupStatusResponse struct {
	Results []GroupStatusResult
}

GroupStatusResponse contains results for one or more shards.

type GroupStatusResult

type GroupStatusResult struct {
	Shard        string
	Key          string
	Size         int32
	Template     string
	InstanceType string
	SubnetPool   string
	Vars         map[string]string
	IsStatic     bool
	Error        error
}

GroupStatusResult represents detailed status of a group from a shard.

type NonceRequest

type NonceRequest struct {
	ClusterID string
	Tenant    string
	Expiry    time.Duration
}

NonceRequest contains parameters for generating a registration nonce.

type NonceResponse

type NonceResponse struct {
	JWT string
}

NonceResponse contains the generated nonce JWT.

type NonceService

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

NonceService generates operator registration nonces.

func NewNonceService

func NewNonceService(store secrets.Store) *NonceService

NewNonceService creates a new NonceService.

func (*NonceService) Generate

func (s *NonceService) Generate(ctx context.Context, req NonceRequest) (*NonceResponse, error)

Generate creates a new operator registration nonce JWT.

type ShardRefreshResult

type ShardRefreshResult struct {
	Shard   string
	Updated bool
	Etag    string
	Error   error
}

ShardRefreshResult represents the result of refreshing a single shard.

type ShardServer

type ShardServer struct {
	ShardID string
	Address string // host:port for operator gRPC
}

ShardServer represents a shard and its operator endpoint.

func ParseServersFlag

func ParseServersFlag(servers string) ([]ShardServer, error)

ParseServersFlag parses "shard1=host1:port1,shard2=host2:port2" format.

type ShardStatus

type ShardStatus struct {
	Shard        string
	Etag         string
	LastModified time.Time
	Size         int64
	Error        error
}

ShardStatus represents the configuration status of a single shard.

Jump to

Keyboard shortcuts

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