Documentation
¶
Index ¶
- func BackupDatabase(ctx context.Context, source, destination string) (string, error)
- type ConnectionRepository
- type NodeStore
- func (store *NodeStore) AppendOperation(ctx context.Context, operation node.Operation) (node.Operation, bool, error)
- func (store *NodeStore) AppliedOperationIDs(ctx context.Context, nodeID string) ([]string, error)
- func (store *NodeStore) Enroll(ctx context.Context, nodeID string, enrollment node.Enrollment) (node.Record, error)
- func (store *NodeStore) ExpireLeases(ctx context.Context, now time.Time) ([]node.Record, error)
- func (store *NodeStore) Find(ctx context.Context, nodeID string) (node.Record, error)
- func (store *NodeStore) Get(ctx context.Context, nodeID string) (node.Record, error)
- func (store *NodeStore) Heartbeat(ctx context.Context, nodeID string, facts capability.NodeFacts, ...) (node.Record, error)
- func (store *NodeStore) Invite(ctx context.Context, record node.Record) error
- func (store *NodeStore) LatestWorkload(ctx context.Context, nodeID, runID, attemptID string) (capability.WorkloadObservation, bool, error)
- func (store *NodeStore) List(ctx context.Context) ([]node.Record, error)
- func (store *NodeStore) PendingOperations(ctx context.Context, nodeID string) ([]node.Operation, error)
- func (store *NodeStore) RecordEvent(ctx context.Context, event node.Event) (bool, error)
- func (store *NodeStore) Reinvite(ctx context.Context, nodeID, enrollmentTokenID string, expires time.Time) error
- func (store *NodeStore) Retire(ctx context.Context, nodeID string) error
- func (store *NodeStore) SettleOperation(ctx context.Context, nodeID string, result node.Result) error
- func (store *NodeStore) Workloads(ctx context.Context, nodeID string) ([]capability.WorkloadObservation, error)
- type PreparationClock
- type RentalScheduleStore
- type RentalStore
- type RunStore
- func (store *RunStore) Append(ctx context.Context, request eventlog.AppendRequest, next domain.RunRecord) (eventlog.AppendResult, error)
- func (store *RunStore) List(ctx context.Context, request runprojection.PageRequest) (runprojection.Page, error)
- func (store *RunStore) ListOpenIDs(ctx context.Context) ([]string, error)
- func (store *RunStore) MarkRebuilt(ctx context.Context) error
- func (store *RunStore) Replace(ctx context.Context, records []domain.RunRecord) error
- func (store *RunStore) RequiresRebuild(ctx context.Context) (bool, error)
- type Storage
- func (s *Storage) Close() error
- func (s *Storage) Connections(sealer credentialSealer) (*ConnectionRepository, error)
- func (s *Storage) CredentialStore() *credential.SQLiteStore
- func (s *Storage) EventLog() *eventlog.SQLiteEventLog
- func (s *Storage) Nodes() *NodeStore
- func (s *Storage) Preparation() *PreparationClock
- func (s *Storage) RentalSchedules() *RentalScheduleStore
- func (s *Storage) Rentals() *RentalStore
- func (s *Storage) Runs() *RunStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackupDatabase ¶ added in v0.6.0
BackupDatabase writes a consistent copy of the database file at source to destination, and answers with the path it wrote.
It exists because the documented recovery procedure shelled out to the `sqlite3` CLI, which Mercator does not ship: the daemon is built on modernc.org/sqlite, a pure-Go SQLite with no binary beside it, so the one documented way to take a backup was a command that is absent from the container image and from most hosts. A recovery procedure nobody can run is not a recovery procedure.
VACUUM INTO is SQLite's own online backup. It reads the source inside a single read transaction, so the copy is the database as of one instant even while a server is writing to it, and it writes a defragmented file rather than a byte copy, so the result needs no companion -wal or -shm file to be complete.
It deliberately does not open a Storage. Opening one runs every migration and purges the credentials of deleted connections, which are writes, and a process taking a copy of a live server's database has no business writing to it.
Both paths are resolved to absolute ones before anything opens them, because this process and SQLite both read them and they agree only on that form. SQLite takes a destination beginning with "file:" as a URI, so `mercator backup file:latest.db` used to write the copy over "latest.db" while claiming an empty file literally named "file:latest.db", destroying whatever the real path held and reporting the wrong file as the backup. The source is read by SQLite alone, through the URI below, which renders a relative path with an authority: a deployment served with MERCATOR_SQLITE_DSN=file:mercator.db, which starts and serves normally, was refused every backup with "invalid uri authority: mercator.db".
Types ¶
type ConnectionRepository ¶
type ConnectionRepository struct {
*eventlog.SQLiteEventLog
// contains filtered or unexported fields
}
func (*ConnectionRepository) CreateCredential ¶
func (r *ConnectionRepository) CreateCredential(ctx context.Context, request eventlog.AppendRequest, write connection.CredentialWrite) (eventlog.AppendResult, error)
func (*ConnectionRepository) DeleteCredential ¶
func (r *ConnectionRepository) DeleteCredential(ctx context.Context, request eventlog.AppendRequest, ref connection.CredentialRef) (eventlog.AppendResult, error)
type NodeStore ¶ added in v0.6.0
type NodeStore struct {
// contains filtered or unexported fields
}
NodeStore is the durable node registry. A registry that forgets across a restart cannot promise not to launch twice, so every fact the reconciliation path needs is written here before a command reaches a node.
func (*NodeStore) AppendOperation ¶ added in v0.6.0
func (*NodeStore) AppliedOperationIDs ¶ added in v0.6.0
func (*NodeStore) ExpireLeases ¶ added in v0.6.0
func (*NodeStore) LatestWorkload ¶ added in v0.6.0
func (store *NodeStore) LatestWorkload( ctx context.Context, nodeID, runID, attemptID string, ) (capability.WorkloadObservation, bool, error)
func (*NodeStore) PendingOperations ¶ added in v0.6.0
func (*NodeStore) RecordEvent ¶ added in v0.6.0
func (*NodeStore) SettleOperation ¶ added in v0.6.0
func (*NodeStore) Workloads ¶ added in v0.6.0
func (store *NodeStore) Workloads(ctx context.Context, nodeID string) ([]capability.WorkloadObservation, error)
type PreparationClock ¶ added in v0.6.0
type PreparationClock struct {
// contains filtered or unexported fields
}
PreparationClock is when this control plane last began preparing content for work it has not admitted. There is one row because the bound it serves is the fleet's: what it protects is a machine's link and this process's own egress, and every Run shares both.
It records a decision Mercator made rather than anything a machine holds, which is what makes it durable state Mercator is allowed to keep. The desired sets stay in process for the opposite reason: they are a cache's contents seen from here, they are derived from the event log, and restating one is answered Duplicate.
func (*PreparationClock) LastBegan ¶ added in v0.6.0
LastBegan is the moment preparation last started, and whether it ever has.
func (*PreparationClock) RecordBegan ¶ added in v0.6.0
RecordBegan stamps the moment preparation started. The latest moment wins however two writers reach it, because the bound is about how recently anything began and a stale write must never make a fresh transfer look old.
type RentalScheduleStore ¶ added in v0.5.0
type RentalScheduleStore struct {
// contains filtered or unexported fields
}
func (*RentalScheduleStore) Commit ¶ added in v0.5.0
func (store *RentalScheduleStore) Commit( ctx context.Context, event eventlog.AppendRequest, expectedVersion uint64, next domain.RentalSchedule, run domain.RunRecord, ) (eventlog.AppendResult, error)
func (*RentalScheduleStore) List ¶ added in v0.5.0
func (store *RentalScheduleStore) List(ctx context.Context) (map[string]domain.RentalSchedule, error)
type RentalStore ¶ added in v0.6.0
type RentalStore struct {
// contains filtered or unexported fields
}
RentalStore is the durable record of the capacity Mercator holds. A control plane that forgot a lease across a restart would leave the machine behind it billing with nothing able to name it, which is why every generation is written here before anything acts on it.
type RunStore ¶ added in v0.6.0
type RunStore struct {
// contains filtered or unexported fields
}
func (*RunStore) Append ¶ added in v0.6.0
func (store *RunStore) Append( ctx context.Context, request eventlog.AppendRequest, next domain.RunRecord, ) (eventlog.AppendResult, error)
func (*RunStore) List ¶ added in v0.6.0
func (store *RunStore) List( ctx context.Context, request runprojection.PageRequest, ) (runprojection.Page, error)
func (*RunStore) ListOpenIDs ¶ added in v0.6.0
func (*RunStore) MarkRebuilt ¶ added in v0.6.0
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
func (*Storage) Connections ¶
func (s *Storage) Connections(sealer credentialSealer) (*ConnectionRepository, error)
func (*Storage) CredentialStore ¶
func (s *Storage) CredentialStore() *credential.SQLiteStore
func (*Storage) EventLog ¶
func (s *Storage) EventLog() *eventlog.SQLiteEventLog
func (*Storage) Nodes ¶ added in v0.6.0
Nodes is the durable registry of enrolled node identities, the commands they were given, and what they reported back.
func (*Storage) Preparation ¶ added in v0.6.0
func (s *Storage) Preparation() *PreparationClock
Preparation is when this control plane last began preparing capacity speculatively, which is the one part of that decision a restart may not forget.
func (*Storage) RentalSchedules ¶ added in v0.5.0
func (s *Storage) RentalSchedules() *RentalScheduleStore
func (*Storage) Rentals ¶ added in v0.6.0
func (s *Storage) Rentals() *RentalStore
Rentals is the durable record of the capacity Mercator holds: the leases it has taken and the generations each of them has been through.