beaconstorage

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package beaconstorage provides a "factory" for beacon stores. A config containing the backend type and the connection string are used to create a specific beacon db.

Index

Constants

View Source
const (
	// BackendKey is the backend key in the config mapping.
	BackendKey = "backend"
	// ConnectionKey is the connection key in the config mapping.
	ConnectionKey = "connection"
)

Variables

This section is empty.

Functions

func NewBeaconCleaner

func NewBeaconCleaner(s Store) *cleaner.Cleaner

NewBeaconCleaner creates a cleaner task, which deletes expired beacons.

func NewRevocationCleaner

func NewRevocationCleaner(s Store) *cleaner.Cleaner

NewRevocationCleaner creates a cleaner task, which deletes expired revocations.

Types

type Backend

type Backend string

Backend indicates the database backend type.

const (

	// BackendSqlite indicates an sqlite backend.
	BackendSqlite Backend = "sqlite"
)

type BeaconDBConf

type BeaconDBConf map[string]string

BeaconDBConf is the configuration for the connection to the trust database.

func (*BeaconDBConf) Backend

func (cfg *BeaconDBConf) Backend() Backend

Backend returns the database backend type.

func (*BeaconDBConf) ConfigName

func (cfg *BeaconDBConf) ConfigName() string

ConfigName is the key in the toml file.

func (*BeaconDBConf) Connection

func (cfg *BeaconDBConf) Connection() string

Connection returns the database connection information.

func (*BeaconDBConf) InitDefaults

func (cfg *BeaconDBConf) InitDefaults()

InitDefaults chooses the sqlite backend if no backend is set and sets all keys to lower case.

func (*BeaconDBConf) MaxIdleConns

func (cfg *BeaconDBConf) MaxIdleConns() (int, bool)

MaxIdleConns returns the limit for maximum idle connections to the database.

func (*BeaconDBConf) MaxOpenConns

func (cfg *BeaconDBConf) MaxOpenConns() (int, bool)

MaxOpenConns returns the limit for maximum open connections to the database.

func (*BeaconDBConf) New

func (cfg *BeaconDBConf) New(ia addr.IA) (beacon.DB, error)

New creates a BeaconDB from the config.

func (*BeaconDBConf) NewCoreStore

func (cfg *BeaconDBConf) NewCoreStore(ia addr.IA, policies beacon.CorePolicies) (Store, error)

NewCoreStore creates a new core beacon store backed by the configured database.

func (*BeaconDBConf) NewStore

func (cfg *BeaconDBConf) NewStore(ia addr.IA, policies beacon.Policies) (Store, error)

NewStore creates a new beacon store backed by the configured database.

func (*BeaconDBConf) Sample

func (cfg *BeaconDBConf) Sample(dst io.Writer, path config.Path, ctx config.CtxMap)

Sample writes a config sample to the writer.

func (*BeaconDBConf) Validate

func (cfg *BeaconDBConf) Validate() error

Validate validates that all values are parsable, and the backend is set.

type Store

type Store interface {
	// PreFilter indicates whether the beacon will be filtered on insert by
	// returning an error with the reason. This allows the caller to drop
	// ignored beacons.
	PreFilter(beacon beacon.Beacon) error
	// BeaconsToPropagate returns a channel that provides all beacons to
	// propagate at the time of the call. The selection is based on the
	// configured propagation policy.
	BeaconsToPropagate(ctx context.Context) (<-chan beacon.BeaconOrErr, error)
	// SegmentsToRegister returns a channel that provides all beacons to
	// register at the time of the call. The selections is based on the
	// configured propagation policy for the requested segment type.
	SegmentsToRegister(ctx context.Context, segType proto.PathSegType) (
		<-chan beacon.BeaconOrErr, error)
	// InsertBeacon adds a verified beacon to the store, ignoring revocations.
	InsertBeacon(ctx context.Context, beacon beacon.Beacon) (beacon.InsertStats, error)
	// InsertRevocations inserts the revocation into the BeaconDB.
	// The provided revocation must be verified by the caller.
	InsertRevocations(ctx context.Context, revocations ...*path_mgmt.SignedRevInfo) error
	// DeleteRevocation deletes the revocation from the BeaconDB.
	DeleteRevocation(ctx context.Context, ia addr.IA, ifid common.IFIDType) error
	// UpdatePolicy updates the policy. Beacons that are filtered by all
	// policies after the update are removed.
	UpdatePolicy(ctx context.Context, policy beacon.Policy) error
	// MaxExpTime returns the segment maximum expiration time for the given policy.
	MaxExpTime(policyType beacon.PolicyType) spath.ExpTimeType
	// DeleteExpired deletes expired Beacons from the store.
	DeleteExpiredBeacons(ctx context.Context) (int, error)
	// DeleteExpiredRevocations deletes expired Revocations from the store.
	DeleteExpiredRevocations(ctx context.Context) (int, error)
	// Close closes the store.
	Close() error
}

Store is the interface to interact with the beacon store.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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