store

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// SyncStatusSynced indicates that a container record is synchronised with the Docker daemon. The record may
	// become outdated even when the status is "synced" if the machine crashes or a network partition occurs.
	// The cluster membership state of the machine should also be checked to determine if the record can be trusted.
	SyncStatusSynced = "synced"
	// SyncStatusOutdated indicates that a container record may be outdated, for example, due to being unable
	// to retrieve the container's state from the Docker daemon or when the machine is being stopped or restarted.
	SyncStatusOutdated = "outdated"
)

Variables

View Source
var (
	//go:embed schema.sql
	Schema string

	ErrKeyNotFound     = errors.New("key not found")
	ErrMachineNotFound = errors.New("machine not found")
)

Functions

This section is empty.

Types

type ContainerRecord

type ContainerRecord struct {
	Container  api.ServiceContainer
	MachineID  string
	SyncStatus string
	UpdatedAt  time.Time
}

type DeleteOptions

type DeleteOptions struct {
	// IDs filters containers by their container IDs.
	IDs []string
	// MachineIDs filters containers by the machine IDs they are running on.
	MachineIDs []string
}

type ListOptions

type ListOptions struct {
	// MachineIDs filters containers by the machine IDs they are running on.
	MachineIDs      []string
	ServiceIDOrName ServiceIDOrNameOptions
}

type MissingChange added in v0.17.1

type MissingChange struct {
	ActorID      string
	StartVersion int64
	EndVersion   int64
}

type ServiceIDOrNameOptions

type ServiceIDOrNameOptions struct {
	ID   string
	Name string
}

ServiceIDOrNameOptions filters containers by the service ID or name they are part of. If both ID and Name are provided, they are combined with an OR operator.

type Store

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

Store is a cluster store backed by a distributed Corrosion database.

func New

func New(corro *corrosion.APIClient) *Store

func (*Store) CreateMachine

func (s *Store) CreateMachine(ctx context.Context, m *pb.MachineInfo) error

func (*Store) CreateOrUpdateContainer

func (s *Store) CreateOrUpdateContainer(ctx context.Context, ctr api.ServiceContainer, machineID string) error

CreateOrUpdateContainer creates a new container record or updates an existing one in the store database. The container is associated with the given machine ID that indicates which machine the container is running on.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, key string) error

func (*Store) DeleteContainers

func (s *Store) DeleteContainers(ctx context.Context, opts DeleteOptions) error

DeleteContainers deletes container records from the store database that match the given options. If no filter is set, all container records are deleted. Filters are combined with AND.

func (*Store) DeleteMachine added in v0.10.0

func (s *Store) DeleteMachine(ctx context.Context, id string) error

func (*Store) Get

func (s *Store) Get(ctx context.Context, key string, value any) error

func (*Store) GetMachine added in v0.10.0

func (s *Store) GetMachine(ctx context.Context, machineID string) (*pb.MachineInfo, error)

func (*Store) KnownMissingChanges added in v0.17.1

func (s *Store) KnownMissingChanges(ctx context.Context) ([]MissingChange, error)

KnownMissingChanges returns a list of currently known missing changes in the Corrosion database.

func (*Store) ListContainers

func (s *Store) ListContainers(ctx context.Context, opts ListOptions) ([]ContainerRecord, error)

ListContainers returns a list of container records from the store database that match the given options. The result excludes orphan containers whose machine is no longer in the cluster.

func (*Store) ListMachines

func (s *Store) ListMachines(ctx context.Context) ([]*pb.MachineInfo, error)

func (*Store) Put

func (s *Store) Put(ctx context.Context, key string, value any) error

func (*Store) SubscribeContainers

func (s *Store) SubscribeContainers(ctx context.Context) ([]ContainerRecord, <-chan struct{}, error)

SubscribeContainers returns a list of containers and a channel that signals changes to the list. The channel doesn't receive any values, it just signals when a container(s) has been added, updated, or deleted in the database. The result excludes orphan containers whose machine is no longer in the cluster. The channel is closed when the containers are no longer subscribable: either the provided context is cancelled or the underlying subscription fails.

func (*Store) SubscribeMachines

func (s *Store) SubscribeMachines(ctx context.Context) ([]*pb.MachineInfo, <-chan struct{}, error)

SubscribeMachines returns a list of machines and a channel that signals changes to the list. The channel doesn't receive any values, it just signals when a machine has been added, updated, or deleted in the database. The channel is closed when the machines are no longer subscribable: either the provided context is cancelled or the underlying subscription fails.

func (*Store) UpdateMachine added in v0.10.0

func (s *Store) UpdateMachine(ctx context.Context, m *pb.MachineInfo) error

func (*Store) Version added in v0.20.0

func (s *Store) Version(ctx context.Context) (map[string]int64, error)

Version returns the cluster store's per-actor version vector: Corrosion actor ID (UUID string) → max received db_version for that actor.

Jump to

Keyboard shortcuts

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