index

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package index is an in-memory index for snapshots.

Index

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 NewDB

func NewDB() *DB

NewDB creates a new, empty in-memory database.

func (*DB) DeleteOldSnapshots

func (d *DB) DeleteOldSnapshots(minTime time.Time) (n int)

DeleteOldSnapshots delete snapshot entry older than the given timestamp.

func (*DB) DeleteSnapshotsByTarget

func (d *DB) DeleteSnapshotsByTarget(target string) int

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

Jump to

Keyboard shortcuts

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