manager

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2025 License: Apache-2.0 Imports: 26 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Op   string          `json:"op"`
	Data json.RawMessage `json:"data"`
}

Command represents a state change operation in the Raft log

type Config

type Config struct {
	NodeID   string
	BindAddr string
	DataDir  string
}

Config holds configuration for creating a Manager

type JoinToken

type JoinToken struct {
	Token     string
	Role      string // "manager" or "worker"
	CreatedAt time.Time
	ExpiresAt time.Time
}

JoinToken represents a token for joining the cluster

type Manager

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

Manager represents a Warren cluster manager node

func NewManager

func NewManager(cfg *Config) (*Manager, error)

NewManager creates a new Manager instance

func (*Manager) AddVoter

func (m *Manager) AddVoter(nodeID, address string) error

AddVoter adds a new manager node to the Raft cluster

func (*Manager) Apply

func (m *Manager) Apply(cmd Command) error

Apply submits a command to the Raft cluster

func (*Manager) Bootstrap

func (m *Manager) Bootstrap() error

Bootstrap initializes a new single-node Raft cluster

func (*Manager) CertToPEM

func (m *Manager) CertToPEM(cert *tls.Certificate) (certPEM, keyPEM []byte, err error)

CertToPEM converts a TLS certificate to PEM format

func (*Manager) CreateIngress

func (m *Manager) CreateIngress(ingress *types.Ingress) error

CreateIngress creates a new ingress via Raft

func (*Manager) CreateNode

func (m *Manager) CreateNode(node *types.Node) error

CreateNode adds a node to the cluster

func (*Manager) CreateSecret

func (m *Manager) CreateSecret(secret *types.Secret) error

CreateSecret creates a new secret (data should already be encrypted)

func (*Manager) CreateService

func (m *Manager) CreateService(service *types.Service) error

CreateService creates a new service

func (*Manager) CreateTLSCertificate

func (m *Manager) CreateTLSCertificate(cert *types.TLSCertificate) error

CreateTLSCertificate creates a new TLS certificate via Raft

func (*Manager) CreateTask

func (m *Manager) CreateTask(task *types.Task) error

CreateTask creates a new task

func (*Manager) CreateVolume

func (m *Manager) CreateVolume(volume *types.Volume) error

CreateVolume creates a new volume

func (*Manager) DeleteIngress

func (m *Manager) DeleteIngress(ingressID string) error

DeleteIngress deletes an ingress via Raft

func (*Manager) DeleteNode

func (m *Manager) DeleteNode(id string) error

DeleteNode removes a node from the cluster

func (*Manager) DeleteSecret

func (m *Manager) DeleteSecret(id string) error

DeleteSecret removes a secret

func (*Manager) DeleteService

func (m *Manager) DeleteService(id string) error

DeleteService removes a service

func (*Manager) DeleteTLSCertificate

func (m *Manager) DeleteTLSCertificate(certID string) error

DeleteTLSCertificate deletes a TLS certificate via Raft

func (*Manager) DeleteTask

func (m *Manager) DeleteTask(id string) error

DeleteTask removes a task

func (*Manager) DeleteVolume

func (m *Manager) DeleteVolume(id string) error

DeleteVolume removes a volume

func (*Manager) EnableACME

func (m *Manager) EnableACME(email string) error

EnableACME initializes the ACME client for Let's Encrypt

func (*Manager) EncryptSecret

func (m *Manager) EncryptSecret(plaintext []byte) ([]byte, error)

EncryptSecret encrypts plaintext secret data

func (*Manager) GenerateJoinToken

func (m *Manager) GenerateJoinToken(role string) (*JoinToken, error)

GenerateJoinToken generates a new join token for adding nodes

func (*Manager) GetCACertPEM

func (m *Manager) GetCACertPEM() []byte

GetCACertPEM returns the CA certificate in PEM format

func (*Manager) GetClusterServers

func (m *Manager) GetClusterServers() ([]raft.Server, error)

GetClusterServers returns information about all servers in the Raft cluster

func (*Manager) GetEventBroker

func (m *Manager) GetEventBroker() *events.Broker

GetEventBroker returns the event broker

func (*Manager) GetIngress

func (m *Manager) GetIngress(id string) (*types.Ingress, error)

GetIngress retrieves an ingress by ID

func (*Manager) GetIngressByName

func (m *Manager) GetIngressByName(name string) (*types.Ingress, error)

GetIngressByName retrieves an ingress by name

func (*Manager) GetNetwork

func (m *Manager) GetNetwork(id string) (*types.Network, error)

GetNetwork retrieves a network by ID (read from local store)

func (*Manager) GetNode

func (m *Manager) GetNode(id string) (*types.Node, error)

GetNode retrieves a node by ID (read from local store)

func (*Manager) GetRaftStats

func (m *Manager) GetRaftStats() map[string]interface{}

GetRaftStats returns Raft statistics

func (*Manager) GetSecret

func (m *Manager) GetSecret(id string) (*types.Secret, error)

GetSecret retrieves a secret by ID (read from local store)

func (*Manager) GetSecretByName

func (m *Manager) GetSecretByName(name string) (*types.Secret, error)

GetSecretByName retrieves a secret by name (read from local store)

func (*Manager) GetService

func (m *Manager) GetService(id string) (*types.Service, error)

GetService retrieves a service by ID (read from local store)

func (*Manager) GetServiceByName

func (m *Manager) GetServiceByName(name string) (*types.Service, error)

GetServiceByName retrieves a service by name (read from local store)

func (*Manager) GetTLSCertificate

func (m *Manager) GetTLSCertificate(id string) (*types.TLSCertificate, error)

GetTLSCertificate retrieves a TLS certificate by ID

func (*Manager) GetTLSCertificateByName

func (m *Manager) GetTLSCertificateByName(name string) (*types.TLSCertificate, error)

GetTLSCertificateByName retrieves a TLS certificate by name

func (*Manager) GetTask

func (m *Manager) GetTask(id string) (*types.Task, error)

GetTask retrieves a task by ID (read from local store)

func (*Manager) GetVolume

func (m *Manager) GetVolume(id string) (*types.Volume, error)

GetVolume retrieves a volume by ID (read from local store)

func (*Manager) GetVolumeByName

func (m *Manager) GetVolumeByName(name string) (*types.Volume, error)

GetVolumeByName retrieves a volume by name (read from local store)

func (*Manager) IsLeader

func (m *Manager) IsLeader() bool

IsLeader returns true if this manager is the Raft leader

func (*Manager) IssueACMECertificate

func (m *Manager) IssueACMECertificate(domains []string) error

IssueACMECertificate requests a new certificate from Let's Encrypt

func (*Manager) IssueCertificate

func (m *Manager) IssueCertificate(nodeID, role string) (*tls.Certificate, error)

IssueCertificate issues a certificate for a node

func (*Manager) Join

func (m *Manager) Join(leaderAddr string, token string) error

Join adds this manager to an existing cluster

func (*Manager) LeaderAddr

func (m *Manager) LeaderAddr() string

LeaderAddr returns the address of the current Raft leader

func (*Manager) ListIngresses

func (m *Manager) ListIngresses() ([]*types.Ingress, error)

ListIngresses lists all ingresses

func (*Manager) ListNetworks

func (m *Manager) ListNetworks() ([]*types.Network, error)

ListNetworks returns all networks (read from local store)

func (*Manager) ListNodes

func (m *Manager) ListNodes() ([]*types.Node, error)

ListNodes returns all nodes (read from local store)

func (*Manager) ListSecrets

func (m *Manager) ListSecrets() ([]*types.Secret, error)

ListSecrets returns all secrets (read from local store)

func (*Manager) ListServices

func (m *Manager) ListServices() ([]*types.Service, error)

ListServices returns all services (read from local store)

func (*Manager) ListTLSCertificates

func (m *Manager) ListTLSCertificates() ([]*types.TLSCertificate, error)

ListTLSCertificates lists all TLS certificates

func (*Manager) ListTasks

func (m *Manager) ListTasks() ([]*types.Task, error)

ListTasks returns all tasks (read from local store)

func (*Manager) ListTasksByNode

func (m *Manager) ListTasksByNode(nodeID string) ([]*types.Task, error)

ListTasksByNode returns all tasks on a node (read from local store)

func (*Manager) ListTasksByService

func (m *Manager) ListTasksByService(serviceID string) ([]*types.Task, error)

ListTasksByService returns all tasks for a service (read from local store)

func (*Manager) ListVolumes

func (m *Manager) ListVolumes() ([]*types.Volume, error)

ListVolumes returns all volumes (read from local store)

func (*Manager) NodeID

func (m *Manager) NodeID() string

NodeID returns the manager's node ID

func (*Manager) PublishEvent

func (m *Manager) PublishEvent(event *events.Event)

PublishEvent publishes an event to all subscribers

func (*Manager) ReloadIngress

func (m *Manager) ReloadIngress() error

ReloadIngress reloads ingress rules from storage

func (*Manager) RemoveServer

func (m *Manager) RemoveServer(nodeID string) error

RemoveServer removes a server from the Raft cluster

func (*Manager) Shutdown

func (m *Manager) Shutdown() error

Shutdown gracefully shuts down the manager

func (*Manager) StartIngress

func (m *Manager) StartIngress() error

StartIngress starts the ingress HTTP proxy on port 80

func (*Manager) StopIngress

func (m *Manager) StopIngress()

StopIngress stops the ingress proxy

func (*Manager) UpdateIngress

func (m *Manager) UpdateIngress(ingress *types.Ingress) error

UpdateIngress updates an ingress via Raft

func (*Manager) UpdateNode

func (m *Manager) UpdateNode(node *types.Node) error

UpdateNode updates a node in the cluster

func (*Manager) UpdateService

func (m *Manager) UpdateService(service *types.Service) error

UpdateService updates an existing service

func (*Manager) UpdateTask

func (m *Manager) UpdateTask(task *types.Task) error

UpdateTask updates a task

func (*Manager) ValidateJoinToken

func (m *Manager) ValidateJoinToken(token string) (string, error)

ValidateJoinToken validates a join token

func (*Manager) ValidateToken

func (m *Manager) ValidateToken(token string) (string, error)

ValidateToken validates a join token and returns the role

type TokenManager

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

TokenManager manages join tokens for the cluster

func NewTokenManager

func NewTokenManager() *TokenManager

NewTokenManager creates a new token manager

func (*TokenManager) CleanupExpiredTokens

func (tm *TokenManager) CleanupExpiredTokens()

CleanupExpiredTokens removes expired tokens

func (*TokenManager) GenerateToken

func (tm *TokenManager) GenerateToken(role string, duration time.Duration) (*JoinToken, error)

GenerateToken generates a new join token

func (*TokenManager) ListTokens

func (tm *TokenManager) ListTokens() []*JoinToken

ListTokens returns all active tokens

func (*TokenManager) RevokeToken

func (tm *TokenManager) RevokeToken(token string)

RevokeToken revokes a join token

func (*TokenManager) ValidateToken

func (tm *TokenManager) ValidateToken(token string) (string, error)

ValidateToken validates a join token and returns its role

type WarrenFSM

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

WarrenFSM implements the Raft Finite State Machine for Warren's cluster state It applies log entries to the cluster state and handles snapshots

func NewWarrenFSM

func NewWarrenFSM(store storage.Store) *WarrenFSM

NewWarrenFSM creates a new FSM instance

func (*WarrenFSM) Apply

func (f *WarrenFSM) Apply(log *raft.Log) interface{}

Apply applies a Raft log entry to the FSM This is called by Raft when a log entry is committed

func (*WarrenFSM) Restore

func (f *WarrenFSM) Restore(rc io.ReadCloser) error

Restore restores the FSM from a snapshot This is called when a node restarts or joins the cluster

func (*WarrenFSM) Snapshot

func (f *WarrenFSM) Snapshot() (raft.FSMSnapshot, error)

Snapshot creates a point-in-time snapshot of the FSM This is called periodically by Raft to compact the log

type WarrenSnapshot

type WarrenSnapshot struct {
	Nodes           []*types.Node
	Services        []*types.Service
	Tasks           []*types.Task
	Secrets         []*types.Secret
	Volumes         []*types.Volume
	Networks        []*types.Network
	Ingresses       []*types.Ingress
	TLSCertificates []*types.TLSCertificate
}

WarrenSnapshot represents a point-in-time snapshot of cluster state

func (*WarrenSnapshot) Persist

func (s *WarrenSnapshot) Persist(sink raft.SnapshotSink) error

Persist writes the snapshot to the given SnapshotSink

func (*WarrenSnapshot) Release

func (s *WarrenSnapshot) Release()

Release releases the snapshot resources

Jump to

Keyboard shortcuts

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