Documentation ¶
Overview ¶
Package persistence defines interfaces and tests for storing log state.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogStatePersistence ¶
type LogStatePersistence interface { // Init sets up the persistence layer. This should be idempotent, // and will be called once per process startup. Init() error // Logs returns the IDs of all logs that have checkpoints that can // be read. Logs() ([]string, error) // ReadOps returns read-only operations for the given log ID. // TODO(al): This method MUST return a valid LogStateReadOps even if // the logID is unknown, otherwise WriteOps will never be called // and the TOFU checkpoint will never be written. ReadOps(logID string) (LogStateReadOps, error) // WriteOps shows intent to write data for the given logID. The // returned operations must have Close() called when the intent // is complete. // There is no requirement that the ID is present in Logs(); if // the ID is not there and this operation succeeds in committing // a checkpoint, then Logs() will return the new ID afterwards. WriteOps(logID string) (LogStateWriteOps, error) }
LogStatePersistence is a handle on persistent storage for log state.
type LogStateReadOps ¶
type LogStateReadOps interface { // GetLatest returns the latest checkpoint. // If no checkpoint exists, it must return codes.NotFound. GetLatest() ([]byte, error) }
LogStateReadOps allows the data about a single log to be read.
type LogStateWriteOps ¶
type LogStateWriteOps interface { LogStateReadOps // Set sets a new checkpoint for the log, committing the state to persistence. // After this call, only Close() should be called on this object. Set(checkpointRaw []byte) error // Terminates the write operation, freeing all resources. // This method MUST be called. Close() error }
LogStateWriteOps allows data about a single log to be read and written in an ACID transaction. This naturally mirrors a DB transaction, but implementations don't need to use a database. Note that Close() must be called whenever these operations are no longer needed.
Directories ¶
Path | Synopsis |
---|---|
Package inmemory provides a persistence implementation that lives only in memory.
|
Package inmemory provides a persistence implementation that lives only in memory. |
Package sql provides log state persistence backed by a SQL database.
|
Package sql provides log state persistence backed by a SQL database. |
Click to show internal directories.
Click to hide internal directories.