gotx

package
v0.0.0-...-4e871e4 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewShardingTransactor

func NewShardingTransactor(connectionProvider ConnectionProvider, shardKeyProvider ShardKeyProvider) gotx.Transactor

func NewTransactor

func NewTransactor(connectionProvider ConnectionProvider) gotx.Transactor

Types

type Client

type Client interface {
	Exec(query string, args ...interface{}) (sql.Result, error)
	Query(query string, args ...interface{}) (*sql.Rows, error)
	QueryRow(query string, args ...interface{}) *sql.Row
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

type ClientProvider

type ClientProvider interface {
	CurrentClient(ctx context.Context) Client
}

func NewDefaultClientProvider

func NewDefaultClientProvider(connectionProvider ConnectionProvider) ClientProvider

func NewShardingDefaultClientProvider

func NewShardingDefaultClientProvider(connectionProvider ConnectionProvider, shardKeyProvider ShardKeyProvider) ClientProvider

type Conn

type Conn interface {
	Client
	BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
}

type ConnectionProvider

type ConnectionProvider interface {
	CurrentConnection(ctx context.Context) Conn
}

-------------------------------- Connection --------------------------------

func NewDefaultConnectionProvider

func NewDefaultConnectionProvider(db Conn) ConnectionProvider

func NewShardingConnectionProvider

func NewShardingConnectionProvider(db []*sql.DB, maxSlot uint32, shardKeyProvider ShardKeyProvider) ConnectionProvider

type DefaultClientProvider

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

func (*DefaultClientProvider) CurrentClient

func (p *DefaultClientProvider) CurrentClient(ctx context.Context) Client

type DefaultConnectionProvider

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

get db connection from field

func (*DefaultConnectionProvider) CurrentConnection

func (p *DefaultConnectionProvider) CurrentConnection(_ context.Context) Conn

type ShardKeyProvider

type ShardKeyProvider func(ctx context.Context) string

type ShardingConnectionProvider

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

get db by hash slot

func (*ShardingConnectionProvider) CurrentConnection

func (p *ShardingConnectionProvider) CurrentConnection(ctx context.Context) Conn

type Transactor

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

------------------------------------ Transactor ------------------------------------

func (*Transactor) Required

func (t *Transactor) Required(ctx context.Context, fn gotx.DoInTransaction, options ...gotx.Option) error

func (*Transactor) RequiresNew

func (t *Transactor) RequiresNew(ctx context.Context, fn gotx.DoInTransaction, options ...gotx.Option) (err error)

Jump to

Keyboard shortcuts

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