storage

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 24 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"
	DefaultDRKeyLevel1DBPath = "/share/cache/%s.drkey_level1.db"
	DefaultDRKeyLevel2DBPath = "/share/cache/%s.drkey_level2.db"
	DefaultDRKeySVDBPath     = "/share/cache/%s.drkey_secret_value.db"
)

Variables

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

Default samples for various databases.

Functions

func NewDRKeyLevel1Storage added in v0.9.0

func NewDRKeyLevel1Storage(c DBConfig) (drkey.Level1DB, error)

func NewDRKeyLevel2Storage added in v0.9.0

func NewDRKeyLevel2Storage(c DBConfig) (drkey.Level2DB, error)

func NewDRKeySecretValueStorage added in v0.9.0

func NewDRKeySecretValueStorage(c DBConfig) (drkey.SecretValueDB, error)

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

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

type PathDB interface {
	io.Closer
	pathdb.DB
}

func NewPathStorage

func NewPathStorage(c DBConfig) (PathDB, error)

type TrustDB

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 db contains common database abstractions for our infra.
Package db contains common database abstractions for our infra.
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