backend

package
v0.0.0-...-89d789c Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2022 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SelectorNameUnknown = "unknown"
	SelectorNameRandom  = "random"
)
View Source
const RestoreSetVariableFlags = format.RestoreStringSingleQuotes
View Source
const (
	SelectorTypeRandom = 1 + iota
)

Variables

View Source
var (
	ErrNoBackendAddr   = errors.New("no backend addr")
	ErrBackendClosed   = errors.New("backend is closed")
	ErrBackendNotFound = errors.New("backend not found")
)
View Source
var (
	ErrNoInstanceToSelect  = errors.New("no instance to select")
	ErrInvalidSelectorType = errors.New("invalid selector type")
)

Functions

func SelectorNameToType

func SelectorNameToType(name string) (int, bool)

func SelectorTypeToName

func SelectorTypeToName(t int) (string, bool)

Types

type BackendConfig

type BackendConfig struct {
	Addrs        map[string]struct{}
	UserName     string
	Password     string
	Capacity     int
	IdleTimeout  time.Duration
	SelectorType int
}

type BackendImpl

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

func NewBackendImpl

func NewBackendImpl(ns string, cfg *BackendConfig) *BackendImpl

func (*BackendImpl) Close

func (b *BackendImpl) Close()

func (*BackendImpl) GetConn

func (*BackendImpl) GetPooledConn

func (b *BackendImpl) GetPooledConn(ctx context.Context) (driver.PooledBackendConn, error)

func (*BackendImpl) Init

func (b *BackendImpl) Init() error

type Config

type Config struct {
	Addr     string
	UserName string
	Password string
}

type ConnPool

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

func NewConnPool

func NewConnPool(ns string, cfg *ConnPoolConfig) *ConnPool

func (*ConnPool) Close

func (c *ConnPool) Close() error

func (*ConnPool) GetConn

func (*ConnPool) Init

func (c *ConnPool) Init() error

type ConnPoolConfig

type ConnPoolConfig struct {
	Config
	Capacity    int
	IdleTimeout time.Duration
}

type Instance

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

func (*Instance) Addr

func (i *Instance) Addr() string

type RandomSelector

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

func NewRandomSelector

func NewRandomSelector(rd *rand2.Rand) *RandomSelector

func (*RandomSelector) Select

func (s *RandomSelector) Select(instances []*Instance) (*Instance, error)

type Selector

type Selector interface {
	Select(instances []*Instance) (*Instance, error)
}

func CreateSelector

func CreateSelector(selectorType int) (Selector, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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