common

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: Apache-2.0 Imports: 12 Imported by: 6

Documentation

Index

Constants

View Source
const (
	DefaultMaxIdleConns                         = 2
	DefaultMaxIdleTime                          = time.Minute
	DefaultPersistence  driver2.PersistenceName = "default"
)

Variables

This section is empty.

Functions

func Close

func Close(readDB, writeDB *sql.DB) error

func CopyPtr

func CopyPtr[T any](t T) *T

func GetPersistenceName

func GetPersistenceName(cs ConfigProvider, prefix string) driver2.PersistenceName

Types

type BaseDB

type BaseDB[T DBTransaction] struct {
	Txn T
	// contains filtered or unexported fields
}

func NewBaseDB

func NewBaseDB[T DBTransaction](newTransaction func() (T, error)) *BaseDB[T]

func (*BaseDB[T]) BeginUpdate

func (db *BaseDB[T]) BeginUpdate() error

func (*BaseDB[T]) Commit

func (db *BaseDB[T]) Commit() error

func (*BaseDB[T]) Discard

func (db *BaseDB[T]) Discard() error

func (*BaseDB[T]) IsTxnNil

func (db *BaseDB[T]) IsTxnNil() bool

type Config

type Config struct {
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig(configProvider ConfigProvider) *Config

func (*Config) GetDriverType

func (c *Config) GetDriverType(name driver2.PersistenceName) (driver.PersistenceType, error)

func (*Config) UnmarshalDriverOpts

func (c *Config) UnmarshalDriverOpts(name driver2.PersistenceName, v any) error

type ConfigProvider

type ConfigProvider interface {
	// IsSet checks to see if the key has been set in any of the data locations
	IsSet(key string) bool
	// UnmarshalKey takes the value corresponding to the passed key and unmarshals it into the passed structure
	UnmarshalKey(key string, rawVal interface{}) error
}

type DBObject

type DBObject interface {
	CreateSchema() error
}

type DBTransaction

type DBTransaction interface {
	Commit() error
	Rollback() error
}

type RWDB

type RWDB struct {
	ReadDB  *sql.DB
	WriteDB *sql.DB
}

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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