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
- func NewBeaconCleaner(s Store) *cleaner.Cleaner
- func NewRevocationCleaner(s Store) *cleaner.Cleaner
- type Backend
- type BeaconDBConf
- func (cfg *BeaconDBConf) Backend() Backend
- func (cfg *BeaconDBConf) ConfigName() string
- func (cfg *BeaconDBConf) Connection() string
- func (cfg *BeaconDBConf) InitDefaults()
- func (cfg *BeaconDBConf) MaxIdleConns() (int, bool)
- func (cfg *BeaconDBConf) MaxOpenConns() (int, bool)
- func (cfg *BeaconDBConf) New(ia addr.IA) (beacon.DB, error)
- func (cfg *BeaconDBConf) NewCoreStore(ia addr.IA, policies beacon.CorePolicies) (Store, error)
- func (cfg *BeaconDBConf) NewStore(ia addr.IA, policies beacon.Policies) (Store, error)
- func (cfg *BeaconDBConf) Sample(dst io.Writer, path config.Path, ctx config.CtxMap)
- func (cfg *BeaconDBConf) Validate() error
- type Store
Constants ¶
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 ¶
NewBeaconCleaner creates a cleaner task, which deletes expired beacons.
func NewRevocationCleaner ¶
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 ¶
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) 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 ¶
NewStore creates a new beacon store backed by the configured database.
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.