Documentation ¶
Overview ¶
Package index is an in-memory index for snapshots.
Index ¶
- type DB
- func (d *DB) DeleteOldSnapshots(minTime time.Time) (n int)
- func (d *DB) DeleteSnapshotsByTarget(target string) int
- func (d *DB) GetAllSnapshots() (entries []*SnapshotEntry)
- func (d *DB) GetBestSnapshots(max int) (entries []*SnapshotEntry)
- func (d *DB) GetSnapshotsByTarget(target string) (entries []*SnapshotEntry)
- func (d *DB) UpsertSnapshots(entries ...*SnapshotEntry)
- type SnapshotEntry
- type SnapshotKey
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
DB *memdb.MemDB
}
func (*DB) DeleteOldSnapshots ¶
DeleteOldSnapshots delete snapshot entry older than the given timestamp.
func (*DB) DeleteSnapshotsByTarget ¶
DeleteSnapshotsByTarget deletes all snapshots owned by a given target. Returns the number of deletions made.
func (*DB) GetAllSnapshots ¶ added in v0.0.2
func (d *DB) GetAllSnapshots() (entries []*SnapshotEntry)
GetAllSnapshots returns a list of all snapshots.
func (*DB) GetBestSnapshots ¶
func (d *DB) GetBestSnapshots(max int) (entries []*SnapshotEntry)
GetBestSnapshots returns newest-to-oldest snapshots. The `max` argument controls the max number of snapshots to return. If max is negative, it returns all snapshots.
func (*DB) GetSnapshotsByTarget ¶
func (d *DB) GetSnapshotsByTarget(target string) (entries []*SnapshotEntry)
GetSnapshotsByTarget returns all snapshots served by a host ordered by newest to oldest.
func (*DB) UpsertSnapshots ¶
func (d *DB) UpsertSnapshots(entries ...*SnapshotEntry)
UpsertSnapshots inserts the given snapshot entries. All entries must come from the same given target.
Snapshots that have the same (target, slot) combination get replaced. Returns the number of snapshots that have been replaced (excluding new inserts).
type SnapshotEntry ¶
type SnapshotEntry struct { SnapshotKey Info *types.SnapshotInfo `json:"info"` UpdatedAt time.Time `json:"updated_at"` }
type SnapshotKey ¶
type SnapshotKey struct { Target string `json:"target"` InverseSlot uint64 `json:"inverse_slot"` // newest-to-oldest sort }
func NewSnapshotKey ¶
func NewSnapshotKey(target string, slot uint64) SnapshotKey
func (SnapshotKey) Slot ¶
func (k SnapshotKey) Slot() uint64