factory

package
Version: v0.2.6 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: Apache-2.0 Imports: 10 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultFactory

type DefaultFactory struct {
	MaxConn         int
	MaxIdleConn     int
	ConnMaxLifetime time.Duration
	Log             logging.LogFunc

	DataSource datasource.DataSource
	// contains filtered or unexported fields
}

func (*DefaultFactory) Close added in v0.0.5

func (f *DefaultFactory) Close() error

func (*DefaultFactory) CreateExecutor added in v0.0.4

func (f *DefaultFactory) CreateExecutor(transaction transaction.Transaction) executor.Executor

func (*DefaultFactory) CreateSession

func (f *DefaultFactory) CreateSession() session.SqlSession

func (*DefaultFactory) CreateTransaction added in v0.0.4

func (f *DefaultFactory) CreateTransaction() transaction.Transaction

func (*DefaultFactory) GetDataSource added in v0.1.0

func (f *DefaultFactory) GetDataSource() datasource.DataSource

func (*DefaultFactory) InitDB deprecated

func (f *DefaultFactory) InitDB() error

Deprecated: Use Open instead

func (*DefaultFactory) LogFunc

func (f *DefaultFactory) LogFunc() logging.LogFunc

func (*DefaultFactory) Open added in v0.1.0

func (*DefaultFactory) WithLock added in v0.0.5

func (f *DefaultFactory) WithLock(lockFunc func(fac *DefaultFactory))

type DefaultMultiSource added in v0.2.4

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

func NewMultiSource added in v0.2.4

func NewMultiSource(t LoadBalanceType) *DefaultMultiSource

func (*DefaultMultiSource) Bind added in v0.2.4

func (lb *DefaultMultiSource) Bind(action string, weight int, factory Factory)

func (*DefaultMultiSource) Select added in v0.2.4

func (lb *DefaultMultiSource) Select(action string) Factory

type Factory

type Factory interface {
	Open(datasource.DataSource) error
	Close() error

	GetDataSource() datasource.DataSource

	CreateTransaction() transaction.Transaction
	CreateExecutor(transaction.Transaction) executor.Executor
	CreateSession() session.SqlSession
	LogFunc() logging.LogFunc
}

type LoadBalanceType added in v0.2.4

type LoadBalanceType int
const (
	LBRoundRobbin       LoadBalanceType = loadbalance.LBRoundRobbin
	LBRoundRobbinWeight LoadBalanceType = loadbalance.LBRoundRobbinWeight
	LBRandom            LoadBalanceType = loadbalance.LBRandom
	LBRandomWeight      LoadBalanceType = loadbalance.LBRandomWeight

	DefaultGroup = "default"
)

type Manager added in v0.2.4

type Manager interface {
	Bind(action string, weight int, factory Factory)
	Select(action string) Factory
}

type SingleSource added in v0.2.4

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

func NewSingleSource added in v0.2.4

func NewSingleSource(fac Factory) *SingleSource

func (*SingleSource) Bind added in v0.2.4

func (lb *SingleSource) Bind(action string, weight int, factory Factory)

func (*SingleSource) Select added in v0.2.4

func (lb *SingleSource) Select(action string) Factory

Jump to

Keyboard shortcuts

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