Documentation
¶
Overview ¶
Copyright 2021-2023 Contributors to the Veraison project. SPDX-License-Identifier: Apache-2.0
Copyright 2021-2023 Contributors to the Veraison project. SPDX-License-Identifier: Apache-2.0
Copyright 2021-2023 Contributors to the Veraison project. SPDX-License-Identifier: Apache-2.0
Copyright 2022-2023 Contributors to the Veraison project. SPDX-License-Identifier: Apache-2.0
Copyright 2021-2023 Contributors to the Veraison project. SPDX-License-Identifier: Apache-2.0
Copyright 2021-2025 Contributors to the Veraison project. SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- Variables
- type IKVStore
- type Memory
- func (o *Memory) Add(key string, val string) error
- func (o *Memory) Close() error
- func (o *Memory) Del(key string) error
- func (o Memory) Dump()
- func (o Memory) Get(key string) ([]string, error)
- func (o Memory) GetKeys() ([]string, error)
- func (o *Memory) Init(unused *viper.Viper, logger *zap.SugaredLogger) error
- func (o *Memory) Set(key string, val string) error
- func (o *Memory) Setup() error
- type SQL
- func (o SQL) Add(key string, val string) error
- func (o *SQL) Close() error
- func (o SQL) Del(key string) error
- func (o SQL) Get(key string) ([]string, error)
- func (o SQL) GetKeys() ([]string, error)
- func (o *SQL) Init(v *viper.Viper, logger *zap.SugaredLogger) error
- func (o SQL) Set(key string, val string) error
- func (o SQL) Setup() error
Constants ¶
const (
DirectiveBackend = "backend"
)
Common directives -- MUST NOT be reused by specialisations
Variables ¶
var ( DefaultTableName = "kvstore" DefaultMaxConnections = 10 )
var ErrKeyNotFound = errors.New("key not found")
Functions ¶
This section is empty.
Types ¶
type IKVStore ¶
type IKVStore interface {
// Init initializes the store. The parameters expected inside
// viper.Viper are implementation-specific -- please see the
// documentation for the implementation you're using.
Init(v *viper.Viper, logger *zap.SugaredLogger) error
// Close the store, shutting down the underlying connection (if one
// exists in the implementation), and disallowing any further
// operations.
Close() error
// Setup a new store for use. What this actually entails is specific
// to a backend.
Setup() error
// Get returns a []string of values for the specified key. If the
// specified key is not in the store, a ErrKeyNotFound is returned. The
// values are in the order they were added, with the most recent value
// last.
Get(key string) ([]string, error)
// GetKeys returns a []string of keys currently set in the store.
GetKeys() ([]string, error)
// Set the specified key to the specified value, discarding any
// existing values.
Set(key, val string) error
// Del removes the specified key from the store, discarding its
// associated values. If the key does not exist, ErrKeyNotFound will be
// returned.
Del(key string) error
// Add the specified value to the specified key. If the key does
// not already exist, this behaves like Set. If the key exists, the
// specified val is appended to the existing value(s).
Add(key, val string) error
}
IKVStore is the interface to a key-value store. Keys and values are both strings. A key can be associated with multiple values.
type Memory ¶
type SQL ¶
type SQL struct {
TableName string
DB *sql.DB
Placeholder sq.PlaceholderFormat
// contains filtered or unexported fields
}
func (*SQL) Init ¶
Init initializes the KVStore. The config may contain the following values, all of which are optional: "sql.tablename" - The name of the table with key-values pairs (defaults to
"kvstore".
"sql.driver" - The SQL driver to use; see
https://github.com/golang/go/wiki/SQLDrivers (defaults to "sqlite3").
"sql.datasource" - The name of the data source to use. Valid values are
driver-specific (defaults to "db=veraison.sql".