Documentation ¶
Index ¶
- func Scan[T any](rows Rows, pointers func(*T) []interface{}) ([]T, error)
- type ConnOpener
- type DB
- func (db *DB[T]) Close()
- func (db *DB[T]) GetConn(ctx context.Context, strategy GetNodeStragegy) (T, error)
- func (db *DB[T]) GetDefaultConn(ctx context.Context) (T, error)
- func (db *DB[T]) GetReadFromConn(ctx context.Context) (T, error)
- func (db *DB[T]) GetWriteToConn(ctx context.Context) (T, error)
- func (db *DB[T]) WithCtx(ctx context.Context) *DB[T]
- func (db *DB[T]) WithDefaultNodeStrategy(strategy GetNodeStragegy) *DB[T]
- func (db *DB[T]) WithNodeWaitTimeout(timeout time.Duration) *DB[T]
- func (db *DB[T]) WithReadFromNodeStrategy(strategy GetNodeStragegy) *DB[T]
- func (db *DB[T]) WithWriteToNodeStrategy(strategy GetNodeStragegy) *DB[T]
- type DBxer
- type GetNodeStragegy
- func NoWait(criteria cluster.NodeStateCriteria) GetNodeStragegy
- func NoWaitAlive() GetNodeStragegy
- func NoWaitPrimary() GetNodeStragegy
- func NoWaitPrimaryPreferred() GetNodeStragegy
- func NoWaitStandby() GetNodeStragegy
- func NoWaitStandbyPreferred() GetNodeStragegy
- func WaitForAlive() GetNodeStragegy
- func WaitForPrimary() GetNodeStragegy
- func WaitForPrimaryPreferred() GetNodeStragegy
- func WaitForStandby() GetNodeStragegy
- func WaitForStandbyPreferred() GetNodeStragegy
- type Option
- func WithClusterOptions[T any](options ...cluster.ClusterOption[T]) Option[T]
- func WithCtx[T any](ctx context.Context) Option[T]
- func WithDefaultNodeStrategy[T any](strategy GetNodeStragegy) Option[T]
- func WithNodeWaitTimeout[T any](timeout time.Duration) Option[T]
- func WithReadFromNodeStrategy[T any](strategy GetNodeStragegy) Option[T]
- func WithWriteToNodeStrategy[T any](strategy GetNodeStragegy) Option[T]
- type Row
- type Rows
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ConnOpener ¶
type DB ¶
type DB[T any] struct { Cluster *cluster.Cluster[T] NodeWaitTimeout time.Duration WriteToNodeStrategy GetNodeStragegy // This is used, when we can clearly guess, that query is a write query (for example, Exec()) ReadFromNodeStrategy GetNodeStragegy // This is used, when we can clearly guess, that query is a read query (for example, Query()) DefaultNodeStrategy GetNodeStragegy // This is used, when we can not figure out, what type of request is formed (like Prepare()) Ctx context.Context // contains filtered or unexported fields }
func NewDB ¶
func NewDB[T any](driverName string, dsns []string, connOpener ConnOpener[T], connCloser cluster.ConnCloser[T], nodeChecker cluster.NodeChecker[T], options ...Option[T]) (*DB[T], error)
func (*DB[T]) GetConn ¶ added in v0.0.3
func (db *DB[T]) GetConn(ctx context.Context, strategy GetNodeStragegy) (T, error)
func (*DB[T]) GetDefaultConn ¶ added in v0.0.3
func (*DB[T]) GetReadFromConn ¶ added in v0.0.3
func (*DB[T]) GetWriteToConn ¶ added in v0.0.3
func (*DB[T]) WithDefaultNodeStrategy ¶ added in v0.0.6
func (db *DB[T]) WithDefaultNodeStrategy(strategy GetNodeStragegy) *DB[T]
func (*DB[T]) WithNodeWaitTimeout ¶ added in v0.0.6
func (*DB[T]) WithReadFromNodeStrategy ¶ added in v0.0.6
func (db *DB[T]) WithReadFromNodeStrategy(strategy GetNodeStragegy) *DB[T]
func (*DB[T]) WithWriteToNodeStrategy ¶ added in v0.0.6
func (db *DB[T]) WithWriteToNodeStrategy(strategy GetNodeStragegy) *DB[T]
type DBxer ¶
type DBxer[TConn any, TTx any, TTxOptions any] interface { DoTx(f func(db DBxer[TConn, TTx, TTxOptions]) error, opts TTxOptions) error DoTxContext( ctx context.Context, f func(ctx context.Context, db DBxer[TConn, TTx, TTxOptions]) error, opts TTxOptions) error Tx() (TTx, error) GetConn(ctx context.Context, strategy GetNodeStragegy) (TConn, error) GetWriteToConn(ctx context.Context) (TConn, error) GetReadFromConn(ctx context.Context) (TConn, error) GetDefaultConn(ctx context.Context) (TConn, error) Close() }
type GetNodeStragegy ¶ added in v0.0.3
type GetNodeStragegy struct { Criteria cluster.NodeStateCriteria Wait bool }
func NoWait ¶ added in v0.0.3
func NoWait(criteria cluster.NodeStateCriteria) GetNodeStragegy
func NoWaitAlive ¶ added in v0.0.3
func NoWaitAlive() GetNodeStragegy
func NoWaitPrimary ¶ added in v0.0.3
func NoWaitPrimary() GetNodeStragegy
func NoWaitPrimaryPreferred ¶ added in v0.0.3
func NoWaitPrimaryPreferred() GetNodeStragegy
func NoWaitStandby ¶ added in v0.0.3
func NoWaitStandby() GetNodeStragegy
func NoWaitStandbyPreferred ¶ added in v0.0.3
func NoWaitStandbyPreferred() GetNodeStragegy
func WaitForAlive ¶ added in v0.0.3
func WaitForAlive() GetNodeStragegy
func WaitForPrimary ¶ added in v0.0.3
func WaitForPrimary() GetNodeStragegy
func WaitForPrimaryPreferred ¶ added in v0.0.3
func WaitForPrimaryPreferred() GetNodeStragegy
func WaitForStandby ¶ added in v0.0.3
func WaitForStandby() GetNodeStragegy
func WaitForStandbyPreferred ¶ added in v0.0.3
func WaitForStandbyPreferred() GetNodeStragegy
type Option ¶
func WithClusterOptions ¶
func WithClusterOptions[T any](options ...cluster.ClusterOption[T]) Option[T]
func WithDefaultNodeStrategy ¶ added in v0.0.3
func WithDefaultNodeStrategy[T any](strategy GetNodeStragegy) Option[T]
func WithReadFromNodeStrategy ¶ added in v0.0.3
func WithReadFromNodeStrategy[T any](strategy GetNodeStragegy) Option[T]
func WithWriteToNodeStrategy ¶ added in v0.0.3
func WithWriteToNodeStrategy[T any](strategy GetNodeStragegy) Option[T]
Click to show internal directories.
Click to hide internal directories.