Documentation
¶
Index ¶
- Constants
- Variables
- type ContainerRecord
- type DeleteOptions
- type Keyspace
- func (k *Keyspace) Delete(ctx context.Context, key string, opts KeyspaceDeleteOptions) error
- func (k *Keyspace) Get(ctx context.Context, key string) (Record, error)
- func (k *Keyspace) List(ctx context.Context, prefix string, opts KeyspaceListOptions) ([]Record, error)
- func (k *Keyspace) Put(ctx context.Context, key string, value []byte) error
- type KeyspaceDeleteOptions
- type KeyspaceListOptions
- type ListOptions
- type Record
- type ServiceIDOrNameOptions
- type Store
- func (s *Store) CreateMachine(ctx context.Context, m *pb.MachineInfo) error
- func (s *Store) CreateOrUpdateContainer(ctx context.Context, ctr api.ServiceContainer, machineID string) error
- func (s *Store) Delete(ctx context.Context, key string) errordeprecated
- func (s *Store) DeleteContainers(ctx context.Context, opts DeleteOptions) error
- func (s *Store) DeleteMachine(ctx context.Context, id string) error
- func (s *Store) Get(ctx context.Context, key string, value any) errordeprecated
- func (s *Store) GetMachine(ctx context.Context, machineID string) (*pb.MachineInfo, error)
- func (s *Store) Keyspace(namespace string) (*Keyspace, error)
- func (s *Store) ListContainers(ctx context.Context, opts ListOptions) ([]ContainerRecord, error)
- func (s *Store) ListMachines(ctx context.Context) ([]*pb.MachineInfo, error)
- func (s *Store) Put(ctx context.Context, key string, value any) errordeprecated
- func (s *Store) SubscribeContainers(ctx context.Context) ([]ContainerRecord, <-chan struct{}, error)
- func (s *Store) SubscribeMachines(ctx context.Context) ([]*pb.MachineInfo, <-chan struct{}, error)
- func (s *Store) UpdateMachine(ctx context.Context, m *pb.MachineInfo) error
- func (s *Store) Version(ctx context.Context) (api.StoreVersion, error)
- func (s *Store) WaitForVersion(ctx context.Context, minVersion api.StoreVersion) error
Constants ¶
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 ¶
var ( //go:embed schema.sql Schema string ErrKeyNotFound = errors.New("key not found") ErrMachineNotFound = errors.New("machine not found") )
var ErrInvalidStoreVersion = errors.New("invalid store version")
ErrInvalidStoreVersion indicates an invalid actor UUID in a store version vector.
Functions ¶
This section is empty.
Types ¶
type ContainerRecord ¶
type DeleteOptions ¶
type Keyspace ¶ added in v0.21.0
type Keyspace struct {
// contains filtered or unexported fields
}
Keyspace provides namespace-scoped key-value storage. Keys are relative to the namespace. Prefix operations use simple string-prefix matching.
func (*Keyspace) Delete ¶ added in v0.21.0
Delete deletes key. When Prefix is true, it also deletes every key that starts with key.
func (*Keyspace) Get ¶ added in v0.21.0
Get returns the entry for key. It returns ErrKeyNotFound when the key does not exist.
type KeyspaceDeleteOptions ¶ added in v0.21.0
type KeyspaceDeleteOptions struct {
// Prefix deletes the key and every key that starts with it.
Prefix bool
}
KeyspaceDeleteOptions controls which records Keyspace.Delete deletes.
type KeyspaceListOptions ¶ added in v0.21.0
type KeyspaceListOptions struct {
// KeysOnly omits record values from the query when true.
KeysOnly bool
}
KeyspaceListOptions controls the records returned by Keyspace.List.
type ListOptions ¶
type ListOptions struct {
// MachineIDs filters containers by the machine IDs they are running on.
MachineIDs []string
ServiceIDOrName ServiceIDOrNameOptions
}
type ServiceIDOrNameOptions ¶
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 (*Store) CreateMachine ¶
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) 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 (*Store) GetMachine ¶ added in v0.10.0
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 (*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 ¶
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 (*Store) Version ¶ added in v0.20.0
Version returns the replication progress observed by this store. Each entry maps a Corrosion actor UUID to its highest processed database version. Corrosion also counts versions whose changes were superseded and skipped. Versions at or below a reported version may still be missing or pending locally.
You can use Store.WaitForVersion to wait for replication through these versions, subject to the data-availability limitations documented there.
Capturing a vector does not wait for replication or prevent further writes.
func (*Store) WaitForVersion ¶ added in v0.21.0
WaitForVersion waits until the local store has reached each actor's minimum version in minVersion, with no known missing or pending transactions through those versions from active members. Corrosion may satisfy a version by applying its surviving changes or by marking it complete because its changes have been superseded.
Waiting normally makes the captured data available locally. However, if another write replaces some of that data before it arrives, Corrosion can complete the older version without transferring the replaced data. If the replacement is outside minVersion, this method can return while the affected data is still missing or outdated. This can happen during concurrent updates even when all machines are well connected.
This method does not guarantee an exact snapshot or delivery of every historical value. Callers that require a specific record or condition should verify it after waiting.
The method observes native replication without initiating synchronisation. An empty minVersion requires no replication. The context controls cancellation and the deadline.