storage

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package storage provides factories for various application storage backends.

Index

Constants

View Source
const (
	// BackendSqlite indicates an sqlite backend.
	BackendSqlite Backend = "sqlite"
	// DefaultPath indicates the default connection string for a generic database.
	DefaultPath        = "/share/scion.db"
	DefaultTrustDBPath = "/share/data/%s.trust.db"
	DefaultPathDBPath  = "/share/cache/%s.path.db"
)

Variables

View Source
var (
	SampleBeaconDB = DBConfig{
		Connection: "/share/cache/%s.beacon.db",
	}
	SamplePathDB = DBConfig{
		Connection: DefaultPathDBPath,
	}
	SampleTrustDB = DBConfig{
		Connection: DefaultTrustDBPath,
	}
)

Default samples for various databases.

Functions

func NewRevocationStorage

func NewRevocationStorage() revcache.RevCache

func SetConnLimits

func SetConnLimits(d db.LimitSetter, c DBConfig)

SetConnLimits sets the maximum number of open and idle connections based on the configuration. Limits of 0 mean the Go default will be used.

Types

type Backend

type Backend string

Backend indicates the database backend type.

type BeaconDB added in v0.7.0

type BeaconDB interface {
	io.Closer
	beacon.DB
	beaconstorage.BeaconAPI
}

func NewBeaconStorage

func NewBeaconStorage(c DBConfig, ia addr.IA) (BeaconDB, error)

type DBConfig

type DBConfig struct {
	Connection   string `toml:"connection,omitempty"`
	MaxOpenConns int    `toml:"max_open_conns,omitempty"`
	MaxIdleConns int    `toml:"max_idle_conns,omitempty"`
}

DBConfig is the configuration for the connection to a database.

func SetID

func SetID(cfg DBConfig, id string) *DBConfig

SetID returns a clone of the configuration that has the ID set on the connection string.

func (*DBConfig) ConfigName

func (cfg *DBConfig) ConfigName() string

ConfigName is the key in the toml file.

func (*DBConfig) InitDefaults

func (cfg *DBConfig) InitDefaults()

func (*DBConfig) Sample

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

Sample writes a config sample to the writer.

func (*DBConfig) Validate

func (cfg *DBConfig) Validate() error

func (*DBConfig) WithDefault

func (cfg *DBConfig) WithDefault(path string) config.Defaulter

type PathDB added in v0.7.0

type PathDB interface {
	io.Closer
	pathdb.DB
}

func NewPathStorage

func NewPathStorage(c DBConfig) (PathDB, error)

type TrustDB added in v0.7.0

type TrustDB interface {
	io.Closer
	trust.DB
	truststorage.TrustAPI
}

TrustDB extends the trust.DB interface with methods used outside of the trust package.

func NewTrustStorage

func NewTrustStorage(c DBConfig) (TrustDB, error)

Directories

Path Synopsis
Package beacon defines interfaces that extend the capabilities of a beacon storage compared to the beacon.DB interface.
Package beacon defines interfaces that extend the capabilities of a beacon storage compared to the beacon.DB interface.
Package mock_storage is a generated GoMock package.
Package mock_storage is a generated GoMock package.
Package trust defines interfaces that extend the capabilities of a trust storage compared to the trust.DB interface.
Package trust defines interfaces that extend the capabilities of a trust storage compared to the trust.DB interface.

Jump to

Keyboard shortcuts

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