database

package
v0.54.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AdminDatabaseEncryptedEntities

func AdminDatabaseEncryptedEntities(db DBFunc, mapper *gorpmapper.Mapper) service.Handler

func AdminDatabaseEncryptedTuplesByEntity

func AdminDatabaseEncryptedTuplesByEntity(db DBFunc, mapper *gorpmapper.Mapper) service.Handler

func AdminDatabaseMigrationUnlocked

func AdminDatabaseMigrationUnlocked(db DBFunc) service.Handler

func AdminDatabaseRollEncryptedEntityByPrimaryKey

func AdminDatabaseRollEncryptedEntityByPrimaryKey(db DBFunc, mapper *gorpmapper.Mapper) service.Handler

func AdminDatabaseSignatureResume

func AdminDatabaseSignatureResume(db DBFunc, mapper *gorpmapper.Mapper) service.Handler

func AdminDatabaseSignatureRollEntityByPrimaryKey

func AdminDatabaseSignatureRollEntityByPrimaryKey(db DBFunc, mapper *gorpmapper.Mapper) service.Handler

func AdminDatabaseSignatureTuplesBySigner

func AdminDatabaseSignatureTuplesBySigner(db DBFunc, mapper *gorpmapper.Mapper) service.Handler

func AdminDeleteDatabaseMigration

func AdminDeleteDatabaseMigration(db DBFunc) service.Handler

func AdminGetDatabaseMigration

func AdminGetDatabaseMigration(db DBFunc) service.Handler

func DBMap

func DBMap(m *gorpmapper.Mapper, db *sql.DB) *gorp.DbMap

DBMap returns a proper Initialized gorp.DBMap pointer

Types

type DBConfiguration

type DBConfiguration struct {
	User            string            `toml:"user" default:"cds" json:"user"`
	Role            string            `toml:"role" default:"" commented:"true" comment:"Set a specific role to run SET ROLE for each connection" json:"role"`
	Password        string            `toml:"password" default:"cds" json:"-"`
	Name            string            `toml:"name" default:"cds" json:"name"`
	Schema          string            `toml:"schema" json:"schema"`
	Host            string            `toml:"host" default:"localhost" json:"host"`
	Port            int               `toml:"port" default:"5432" json:"port"`
	SSLMode         string            `toml:"sslmode" default:"disable" comment:"DB SSL Mode: require (default), verify-full, or disable" json:"sslmode"`
	MaxConn         int               `toml:"maxconn" default:"20" comment:"DB Max connection" json:"maxconn"`
	ConnectTimeout  int               `toml:"connectTimeout" default:"10" comment:"Maximum wait for connection, in seconds" json:"connectTimeout"`
	ConnMaxIdleTime string            `` /* 131-byte string literal not displayed */
	ConnMaxLifetime string            `` /* 133-byte string literal not displayed */
	Timeout         int               `toml:"timeout" default:"3000" comment:"Statement timeout value in milliseconds" json:"timeout"`
	SignatureKey    *RollingKeyConfig `json:"-" toml:"signatureRollingKeys" comment:"Signature rolling keys" mapstructure:"signatureRollingKeys"`
	EncryptionKey   *RollingKeyConfig `json:"-" toml:"encryptionRollingKeys" comment:"Encryption rolling keys" mapstructure:"encryptionRollingKeys"`
}

DBConfiguration is the exposed type for database configuration.

type DBConnectionFactory

type DBConnectionFactory struct {
	DBRole            string
	DBUser            string
	DBPassword        string
	DBName            string
	DBSchema          string
	DBHost            string
	DBPort            int
	DBSSLMode         string
	DBTimeout         int
	DBConnectTimeout  int
	DBConnMaxIdleTime string
	DBConnMaxLifetime string
	DBMaxConn         int
	Database          *sql.DB
	// contains filtered or unexported fields
}

DBConnectionFactory is a database connection factory on postgres with gorp

func Init

Init initialize sql.DB object by checking environment variables and connecting to database

func (*DBConnectionFactory) Close

func (f *DBConnectionFactory) Close() error

Close closes the database, releasing any open resources.

func (*DBConnectionFactory) DB

func (f *DBConnectionFactory) DB() *sql.DB

DB returns the current sql.DB object

func (*DBConnectionFactory) GetDBMap

func (f *DBConnectionFactory) GetDBMap(m *gorpmapper.Mapper) func() *gorp.DbMap

GetDBMap returns a gorp.DbMap pointer

func (*DBConnectionFactory) NewListener

func (f *DBConnectionFactory) NewListener(minReconnectInterval time.Duration, maxReconnectInterval time.Duration, eventCallback pq.EventCallbackType) *pq.Listener

NewListener creates a new database connection dedicated to LISTEN / NOTIFY.

func (*DBConnectionFactory) Set

func (f *DBConnectionFactory) Set(d *sql.DB)

Set is for tetsing purpose, we need to set manually the connection

func (*DBConnectionFactory) Status

Status returns database driver and status in a printable string

type DBFunc

type DBFunc func() *gorp.DbMap

type KeyConfig

type KeyConfig struct {
	Timestamp int64  `toml:"timestamp,omitempty" mapstructure:"timestamp"`
	Key       string `toml:"key" mapstructure:"key"`
}

type RollingKeyConfig

type RollingKeyConfig struct {
	Cipher string      `toml:"cipher" mapstructure:"cipher"`
	Keys   []KeyConfig `toml:"keys" mapstructure:"keys"`
}

func (RollingKeyConfig) GetKeys

func (k RollingKeyConfig) GetKeys(identifier string) []keyloader.KeyConfig

type TypeConverter

type TypeConverter struct{}

TypeConverter is a converter type to assign to gorp

func (*TypeConverter) FromDb

func (c *TypeConverter) FromDb(target interface{}) (gorp.CustomScanner, bool)

FromDb is called by gorp to deserialize database values to custom types

func (*TypeConverter) ToDb

func (c *TypeConverter) ToDb(val interface{}) (interface{}, error)

ToDb is called by gorp to serialize custom types to database values

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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