Documentation
¶
Index ¶
- Constants
- Variables
- func NewBytePrimaryKey(name driver.ColumnKey) *primaryKey
- func NewKeyValueStore(dbs *common3.RWDB, tables common4.TableNames) (*common4.KeyValueStore, error)
- func NewNamedDriver(config driver.Config, dbProvider DbProvider) driver.NamedDriver
- func NewPersistenceWithOpts[V common3.DBObject](cfg *ConfigProvider, dbProvider DbProvider, name driver.PersistenceName, ...) (V, error)
- func NewSanitizer() *stringSanitizer
- func NewSimplePrimaryKey(name driver.ColumnKey) *primaryKey
- func Open(opts Opts) (*common.RWDB, error)
- func RegisterTLSConnection(dataSource string, tlsCfg TLSConfig) (string, error)
- func StartPostgres(ctx context.Context, c *ContainerConfig, logger Logger) (func(), string, error)
- func WithBinds(binds ...string) option
- func WithContainerImage(name string) option
- func WithContainerName(name string) option
- func WithDBName(name string) option
- func WithHost(host string) option
- func WithPassword(pw string) option
- func WithPort(port string) option
- func WithUser(user string) option
- type AuditInfoStore
- type BindingStore
- type Config
- type ConfigProvider
- type ContainerConfig
- type DbConfig
- type DbProvider
- type Driver
- func (d *Driver) NewAuditInfo(name driver.PersistenceName, params ...string) (driver.AuditInfoStore, error)
- func (d *Driver) NewBinding(name driver.PersistenceName, params ...string) (driver.BindingStore, error)
- func (d *Driver) NewKVS(name driver.PersistenceName, params ...string) (driver.KeyValueStore, error)
- func (d *Driver) NewSignerInfo(name driver.PersistenceName, params ...string) (driver.SignerInfoStore, error)
- type ErrorMapper
- type KeyValueStoreNotifier
- type Logger
- type Notifierdeprecated
- type Opts
- type SignerInfoStore
- type TLSConfig
Constants ¶
const (
Persistence driver2.PersistenceType = "postgres"
)
Variables ¶
var IsolationLevels = isolationLevelMapper{ driver.LevelDefault: sql.LevelDefault, driver.LevelReadUncommitted: sql.LevelReadUncommitted, driver.LevelReadCommitted: sql.LevelReadCommitted, driver.LevelWriteCommitted: sql.LevelWriteCommitted, driver.LevelRepeatableRead: sql.LevelRepeatableRead, driver.LevelSnapshot: sql.LevelSnapshot, driver.LevelSerializable: sql.LevelSerializable, driver.LevelLinearizable: sql.LevelLinearizable, }
Functions ¶
func NewBytePrimaryKey ¶ added in v0.7.0
func NewKeyValueStore ¶
func NewKeyValueStore(dbs *common3.RWDB, tables common4.TableNames) (*common4.KeyValueStore, error)
func NewNamedDriver ¶
func NewNamedDriver(config driver.Config, dbProvider DbProvider) driver.NamedDriver
func NewPersistenceWithOpts ¶
func NewPersistenceWithOpts[V common3.DBObject](cfg *ConfigProvider, dbProvider DbProvider, name driver.PersistenceName, constructor common2.PersistenceConstructor[V], params ...string) (V, error)
func NewSanitizer ¶
func NewSanitizer() *stringSanitizer
func NewSimplePrimaryKey ¶
func RegisterTLSConnection ¶ added in v0.17.0
RegisterTLSConnection maps the sslmode onto a pgx connection config and registers it with the stdlib driver, returning the datasource name to use with sql.Open. For sslmode=disable it returns the original datasource unchanged, avoiding both the registration and any certificate file access.
Registration is memoized per (dataSource, tlsCfg): identical inputs return the same stdlib name on every call. This keeps the returned name stable so the DB provider's connection-pool cache (keyed on the datasource) still deduplicates stores that share a database, and bounds the number of registered configs to one per distinct configuration.
func StartPostgres ¶
StartPostgres spawns a Postgres container with the given ContainerConfig and Logger. It returns a function to terminate and cleanup the spawned Postgres container, a datasource string that allows to connect to the database. If an error occurs, the closeF is nil and the datasource string is empty.
func WithBinds ¶ added in v0.17.0
func WithBinds(binds ...string) option
WithBinds sets the Docker container binds.
func WithContainerImage ¶ added in v0.7.0
func WithContainerImage(name string) option
WithContainerImage sets the Postgres dbname.
func WithContainerName ¶ added in v0.7.0
func WithContainerName(name string) option
WithContainerName sets the Postgres dbname.
func WithDBName ¶ added in v0.7.0
func WithDBName(name string) option
WithDBName sets the Postgres dbname.
func WithPassword ¶ added in v0.7.0
func WithPassword(pw string) option
WithPassword sets the Postgres port.
Types ¶
type AuditInfoStore ¶
type AuditInfoStore struct {
*common3.AuditInfoStore
}
func NewAuditInfoStore ¶
func NewAuditInfoStore(dbs *common2.RWDB, tables common3.TableNames) (*AuditInfoStore, error)
type BindingStore ¶
type BindingStore struct {
*common3.BindingStore
// contains filtered or unexported fields
}
func NewBindingStore ¶
func NewBindingStore(dbs *common2.RWDB, tables common3.TableNames) (*BindingStore, error)
type ConfigProvider ¶
type ConfigProvider struct {
// contains filtered or unexported fields
}
func NewConfigProvider ¶
func NewConfigProvider(config config) *ConfigProvider
func (*ConfigProvider) GetOpts ¶
func (r *ConfigProvider) GetOpts(name driver.PersistenceName, params ...string) (*Config, error)
type ContainerConfig ¶
ContainerConfig contains the configuration data about a postgres container.
func ConfigFromDataSource ¶ added in v0.7.0
func ConfigFromDataSource(s string) (*ContainerConfig, error)
ConfigFromDataSource returns a Postgres container configuration based on a given postgres connection string.
func ConfigFromEnv ¶ added in v0.7.0
func ConfigFromEnv() *ContainerConfig
ConfigFromEnv returns a Postgres container configuration based environment variables.
func DefaultConfig ¶
func DefaultConfig(opts ...option) *ContainerConfig
DefaultConfig returns a Postgres container configuration. The configuration entries can be set via option parameters.
type DbConfig ¶
DbConfig contains the configuration data about a postgres database.
func (*DbConfig) DataSource ¶
DataSource returns the contents of the DbConfig as data source string.
type DbProvider ¶
func NewDbProvider ¶
func NewDbProvider() DbProvider
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
func NewDriverWithDbProvider ¶
func NewDriverWithDbProvider(config driver.Config, dbProvider DbProvider) *Driver
func (*Driver) NewAuditInfo ¶
func (d *Driver) NewAuditInfo(name driver.PersistenceName, params ...string) (driver.AuditInfoStore, error)
func (*Driver) NewBinding ¶
func (d *Driver) NewBinding(name driver.PersistenceName, params ...string) (driver.BindingStore, error)
func (*Driver) NewKVS ¶
func (d *Driver) NewKVS(name driver.PersistenceName, params ...string) (driver.KeyValueStore, error)
func (*Driver) NewSignerInfo ¶
func (d *Driver) NewSignerInfo(name driver.PersistenceName, params ...string) (driver.SignerInfoStore, error)
type ErrorMapper ¶
type ErrorMapper struct{}
func (*ErrorMapper) WrapError ¶
func (m *ErrorMapper) WrapError(err error) error
type KeyValueStoreNotifier ¶
type KeyValueStoreNotifier struct {
*common4.KeyValueStore
*Notifier
}
func (*KeyValueStoreNotifier) Close ¶ added in v0.7.0
func (db *KeyValueStoreNotifier) Close() error
func (*KeyValueStoreNotifier) CreateSchema ¶
func (db *KeyValueStoreNotifier) CreateSchema() error
type Notifier
deprecated
type Notifier struct {
// contains filtered or unexported fields
}
Notifier implements a simple subscription API to listen for updates on a database table.
Deprecated: Notifier exists to track notification on tokens stored in postgres in the Token SDK. The Token SDK is the only user of this, thus, the code may be migrated. Notifier should not be used anymore.
func NewNotifier ¶
func (*Notifier) CreateSchema ¶
func (*Notifier) UnsubscribeAll ¶
type SignerInfoStore ¶
type SignerInfoStore struct {
*common3.SignerInfoStore
}
func NewSignerInfoStore ¶
func NewSignerInfoStore(dbs *common2.RWDB, tables common3.TableNames) (*SignerInfoStore, error)
type TLSConfig ¶ added in v0.17.0
type TLSConfig struct {
Enabled bool `json:"enabled" mapstructure:"enabled" yaml:"enabled"`
ServerName string `json:"server_name" mapstructure:"server_name" yaml:"server_name"`
CertPath string `json:"cert_path" mapstructure:"cert_path" yaml:"cert_path"`
KeyPath string `json:"key_path" mapstructure:"key_path" yaml:"key_path"`
RootCertPath string `json:"root_cert_path" mapstructure:"root_cert_path" yaml:"root_cert_path"`
SSLMode string `json:"ssl_mode" mapstructure:"ssl_mode" yaml:"ssl_mode"`
}
TLSConfig defines the configuration parameters for securing database connections.