database
v1.0.0
Documentation
pkg.go.dev ↗Variables
DefaultMaxConnections (2 declarations)
var ( DefaultMaxConnections = 60 DefaultConnectionTimeout = 20 * time.Second )
DefaultMaxConnections ...
Types
Database
type Database interface {
Options() Options
Session() interface{}
Close() error
String() string
}
Database ...
DatabasePool
type DatabasePool struct {
// contains filtered or unexported fields
}
DatabasePool implements Database that uses pool of Database
NewDatabasePool
func NewDatabasePool(impls ...Database) DatabasePool
NewDatabasePool takes several implementations of the Database and returns an instance of the Database that uses sync.Pool of given implemetations
DatabasePool.Close
func (_d DatabasePool) Close() (err error)
Close implements Database
DatabasePool.Options
func (_d DatabasePool) Options() (o1 Options)
Options implements Database
DatabasePool.Session
func (_d DatabasePool) Session() (p1 interface{})
Session implements Database
DatabasePool.String
func (_d DatabasePool) String() (s1 string)
String implements Database
DatabaseWithRetry
type DatabaseWithRetry struct {
Database
// contains filtered or unexported fields
}
DatabaseWithRetry implements Database interface instrumented with retries
NewDatabaseWithRetry
func NewDatabaseWithRetry(base Database, retryCount int, retryInterval time.Duration) DatabaseWithRetry
NewDatabaseWithRetry returns DatabaseWithRetry
DatabaseWithRetry.Close
func (_d DatabaseWithRetry) Close() (err error)
Close implements Database
DatabaseWithTracing
type DatabaseWithTracing struct {
Database
// contains filtered or unexported fields
}
DatabaseWithTracing implements Database interface instrumented with opentracing spans
NewDatabaseWithTracing
func NewDatabaseWithTracing(base Database, instance string) DatabaseWithTracing
NewDatabaseWithTracing returns DatabaseWithTracing
Option
type Option func(*Options)
Option ...
ConnectionTimeout
func ConnectionTimeout(t time.Duration) Option
ConnectionTimeout ...
Endpoints
func Endpoints(addrs []string) Option
Endpoints ...
MaxConnections
func MaxConnections(n int) Option
MaxConnections ...
Password
func Password(s string) Option
Password ...
TLSCertificate
func TLSCertificate(s string) Option
TLSCertificate ...
TLSConfig
func TLSConfig(t *tls.Config) Option
TLSConfig ...
Username
func Username(s string) Option
Username ...
UsernamePassword
func UsernamePassword(u string, p string) Option
UsernamePassword ...
Options
type Options struct {
Endpoints []string
Username string
Password string
TLSConfig *tls.Config
MaxConnections int
ConnectionTimeout time.Duration
Context context.Context
}
Options ...
Table
type Table interface {
Name() string
Create(e interface{}) error
Delete() error
Insert(elem interface{}) error
}
Table ...
TablePool
type TablePool struct {
// contains filtered or unexported fields
}
TablePool implements Table that uses pool of Table
NewTablePool
func NewTablePool(impls ...Table) TablePool
NewTablePool takes several implementations of the Table and returns an instance of the Table that uses sync.Pool of given implemetations
TablePool.Create
func (_d TablePool) Create(e interface{}) (err error)
Create implements Table
TablePool.Delete
func (_d TablePool) Delete() (err error)
Delete implements Table
TablePool.Insert
func (_d TablePool) Insert(elem interface{}) (err error)
Insert implements Table
TablePool.Name
func (_d TablePool) Name() (s1 string)
Name implements Table
TableWithRetry
type TableWithRetry struct {
Table
// contains filtered or unexported fields
}
TableWithRetry implements Table interface instrumented with retries
NewTableWithRetry
func NewTableWithRetry(base Table, retryCount int, retryInterval time.Duration) TableWithRetry
NewTableWithRetry returns TableWithRetry
TableWithRetry.Create
func (_d TableWithRetry) Create(e interface{}) (err error)
Create implements Table
TableWithRetry.Delete
func (_d TableWithRetry) Delete() (err error)
Delete implements Table
TableWithRetry.Insert
func (_d TableWithRetry) Insert(elem interface{}) (err error)
Insert implements Table