storage

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: Apache-2.0 Imports: 16 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,
	}
	SampleRenewalDB = DBConfig{
		Connection: "/share/data/trustdb/%s.renewal.db",
	}
	SampleTrustDB = DBConfig{
		Connection: DefaultTrustDBPath,
	}
)

Default samples for various databases.

Functions

func NewBeaconStorage

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

func NewPathStorage

func NewPathStorage(c DBConfig) (pathdb.PathDB, error)

func NewRenewalStorage

func NewRenewalStorage(c DBConfig) (renewal.DB, error)

func NewRevocationStorage

func NewRevocationStorage() revcache.RevCache

func NewTrustStorage

func NewTrustStorage(c DBConfig) (trust.DB, error)

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 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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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