pathdb

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewCleaner

func NewCleaner(db DB, namespace string) *cleaner.Cleaner

NewCleaner creates a cleaner task that deletes expired segments.

func PackSegment

func PackSegment(ps *seg.PathSegment) ([]byte, error)

PackSegment packs a path segment.

func UnpackSegment

func UnpackSegment(raw []byte) (*seg.PathSegment, error)

UnpackSegment unpacks a path segment.

Types

type DB

type DB interface {
	ReadWrite
	BeginTransaction(ctx context.Context, opts *sql.TxOptions) (Transaction, error)
}

DB defines the interface that all DB backends have to implement.

type InsertStats

type InsertStats struct {
	// Inserted is the number of inserted entries.
	Inserted int
	// Updated is the number of updated entries.
	Updated int
}

InsertStats provides statistics about an insertion.

type ReadWrite

type ReadWrite interface {
	// Get returns all path segment(s) matching the parameters specified.
	Get(context.Context, *query.Params) (query.Results, error)
	// GetAll returns a slice which contains all items in the path db. If the path db cannot
	// prepare the query, an empty slice and the error are returned. If the querying succeeds, the
	// slice will be filled with the segments in the database. If an error occurs during reading a
	// segment an empty slice and the error are returned; otherwise, it returns no error and a slice
	// which contains all the path segments in the database. (Note that in this case the slice will
	// be empty if no path segment is found.)
	GetAll(context.Context) (query.Results, error)
	// GetNextQuery returns the nextQuery timestamp for the given src-dst pair
	// and policy , or a zero time if it hasn't been queried.
	GetNextQuery(ctx context.Context, src, dst addr.IA) (time.Time, error)
	// Insert inserts or updates a path segment. It returns the number of path segments
	// that have been inserted/updated.
	Insert(context.Context, *seg.Meta) (InsertStats, error)
	// InsertWithHPGroupIDs inserts or updates a path segment with a set of HPGroupIDs. It
	// returns the number of path segments that have been inserted/updated.
	InsertWithHPGroupIDs(context.Context, *seg.Meta, []uint64) (InsertStats, error)
	// DeleteExpired deletes all paths segments that are expired, using now as a reference.
	// Returns the number of deleted segments.
	DeleteExpired(ctx context.Context, now time.Time) (int, error)
	// InsertNextQuery inserts or updates the timestamp nextQuery for the given
	// src-dst pair and policy. Returns true if an insert/update happened or
	// false if the stored timestamp is already newer.
	InsertNextQuery(ctx context.Context, src, dst addr.IA, nextQuery time.Time) (bool, error)
}

ReadWrite defines all read an write operations of the path DB.

type Transaction

type Transaction interface {
	ReadWrite
	Commit() error
	Rollback() error
}

Directories

Path Synopsis
Package mock_pathdb is a generated GoMock package.
Package mock_pathdb is a generated GoMock package.

Jump to

Keyboard shortcuts

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