namespace

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: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicatedUser      = errors.New("duplicated user")
	ErrInvalidSelectorType = errors.New("invalid selector type")

	ErrNilBreakerName              = errors.New("breaker name nil")
	ErrInvalidFailureRateThreshold = errors.New("invalid FailureRateThreshold")
	ErrInvalidopenStatusDurationMs = errors.New("invalid OpenStatusDurationMs")
	ErrInvalidSqlTimeout           = errors.New("invalid sql timeout")

	ErrInvalidScope = errors.New("invalid scope")
)

Functions

func DefaultAsyncCloseNamespace

func DefaultAsyncCloseNamespace(ns Namespace) error

Types

type Backend

type Backend interface {
	Close()
	GetPooledConn(context.Context) (driver.PooledBackendConn, error)
}

func BuildBackend

func BuildBackend(ns string, cfg *config.BackendNamespace) (Backend, error)

type Breaker

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

func NewBreaker

func NewBreaker(br *config.BreakerInfo) (*Breaker, error)

func (*Breaker) GetBreaker

func (this *Breaker) GetBreaker() (driver.Breaker, error)

type BreakerManager

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

func NewBreakerManager

func NewBreakerManager(br *config.BreakerInfo) (*BreakerManager, error)

func (*BreakerManager) AddTimeWheelTask

func (this *BreakerManager) AddTimeWheelTask(name string, connectionID uint64, flag *int32) error

func (*BreakerManager) CASHalfOpenProbeSent

func (this *BreakerManager) CASHalfOpenProbeSent(name string, idx int, halfOpenProbeSent bool) bool

func (*BreakerManager) CloseBreaker

func (this *BreakerManager) CloseBreaker()

func (*BreakerManager) GetBreakerScope

func (this *BreakerManager) GetBreakerScope() string

func (*BreakerManager) Hit

func (this *BreakerManager) Hit(name string, idx int, isFail bool) error

func (*BreakerManager) IsUseBreaker

func (this *BreakerManager) IsUseBreaker() bool

func (*BreakerManager) RemoveTimeWheelTask

func (this *BreakerManager) RemoveTimeWheelTask(connectionID uint64) error

func (*BreakerManager) Status

func (this *BreakerManager) Status(name string) (int32, int)

type Frontend

type Frontend interface {
	Auth(username string, passwdBytes []byte, salt []byte) bool
	IsDatabaseAllowed(db string) bool
	ListDatabases() []string
	IsDeniedSQL(sqlFeature uint32) bool
	IsAllowedSQL(sqlFeature uint32) bool
}

func BuildFrontend

func BuildFrontend(cfg *config.FrontendNamespace) (Frontend, error)

type FrontendNamespace

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

func (*FrontendNamespace) Auth

func (n *FrontendNamespace) Auth(username string, passwdBytes []byte, salt []byte) bool

func (*FrontendNamespace) IsAllowedSQL

func (n *FrontendNamespace) IsAllowedSQL(sqlFeature uint32) bool

func (*FrontendNamespace) IsDatabaseAllowed

func (n *FrontendNamespace) IsDatabaseAllowed(db string) bool

func (*FrontendNamespace) IsDeniedSQL

func (n *FrontendNamespace) IsDeniedSQL(sqlFeature uint32) bool

func (*FrontendNamespace) ListDatabases

func (n *FrontendNamespace) ListDatabases() []string

type Namespace

type Namespace interface {
	Name() string
	Auth(username string, passwdBytes []byte, salt []byte) bool
	IsDatabaseAllowed(db string) bool
	ListDatabases() []string
	IsDeniedSQL(sqlFeature uint32) bool
	IsAllowedSQL(sqlFeature uint32) bool
	GetPooledConn(context.Context) (driver.PooledBackendConn, error)
	Close()
	GetBreaker() (driver.Breaker, error)
	GetRateLimiter() driver.RateLimiter
}

func BuildNamespace

func BuildNamespace(cfg *config.Namespace) (Namespace, error)

type NamespaceBuilder

type NamespaceBuilder func(cfg *config.Namespace) (Namespace, error)

type NamespaceCloser

type NamespaceCloser func(ns Namespace) error

type NamespaceHolder

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

func CreateNamespaceHolder

func CreateNamespaceHolder(cfgs []*config.Namespace, build NamespaceBuilder) (*NamespaceHolder, error)

func (*NamespaceHolder) Clone

func (n *NamespaceHolder) Clone() *NamespaceHolder

func (*NamespaceHolder) Delete

func (n *NamespaceHolder) Delete(name string)

func (*NamespaceHolder) Get

func (n *NamespaceHolder) Get(name string) (Namespace, bool)

func (*NamespaceHolder) Set

func (n *NamespaceHolder) Set(name string, ns Namespace)

type NamespaceImpl

type NamespaceImpl struct {
	Br driver.Breaker
	Backend
	Frontend
	// contains filtered or unexported fields
}

func (*NamespaceImpl) GetBreaker

func (n *NamespaceImpl) GetBreaker() (driver.Breaker, error)

func (*NamespaceImpl) GetRateLimiter

func (n *NamespaceImpl) GetRateLimiter() driver.RateLimiter

func (*NamespaceImpl) Name

func (n *NamespaceImpl) Name() string

type NamespaceManager

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

func CreateNamespaceManager

func CreateNamespaceManager(cfgs []*config.Namespace, builder NamespaceBuilder, closer NamespaceCloser) (*NamespaceManager, error)

func NewNamespaceManager

func NewNamespaceManager(users *UserNamespaceMapper, nss *NamespaceHolder, builder NamespaceBuilder, closer NamespaceCloser) *NamespaceManager

func (*NamespaceManager) Auth

func (n *NamespaceManager) Auth(username string, pwd, salt []byte) (driver.Namespace, bool)

func (*NamespaceManager) CommitReloadNamespaces

func (n *NamespaceManager) CommitReloadNamespaces(namespaces []string) error

func (*NamespaceManager) PrepareReloadNamespace

func (n *NamespaceManager) PrepareReloadNamespace(namespace string, cfg *config.Namespace) error

func (*NamespaceManager) RemoveNamespace

func (n *NamespaceManager) RemoveNamespace(name string)

type NamespaceRateLimiter

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

func NewNamespaceRateLimiter

func NewNamespaceRateLimiter(scope string, qpsThreshold int) *NamespaceRateLimiter

func (*NamespaceRateLimiter) Limit

func (n *NamespaceRateLimiter) Limit(ctx context.Context, key string) error

func (*NamespaceRateLimiter) Scope

func (n *NamespaceRateLimiter) Scope() string

type NamespaceWrapper

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

func (*NamespaceWrapper) Closed

func (n *NamespaceWrapper) Closed() bool

func (*NamespaceWrapper) DescConnCount

func (n *NamespaceWrapper) DescConnCount()

func (*NamespaceWrapper) GetBreaker

func (n *NamespaceWrapper) GetBreaker() (driver.Breaker, error)

func (*NamespaceWrapper) GetPooledConn

func (n *NamespaceWrapper) GetPooledConn(ctx context.Context) (driver.PooledBackendConn, error)

func (*NamespaceWrapper) GetRateLimiter

func (n *NamespaceWrapper) GetRateLimiter() driver.RateLimiter

func (*NamespaceWrapper) IncrConnCount

func (n *NamespaceWrapper) IncrConnCount()

func (*NamespaceWrapper) IsAllowedSQL

func (n *NamespaceWrapper) IsAllowedSQL(sqlFeature uint32) bool

func (*NamespaceWrapper) IsDatabaseAllowed

func (n *NamespaceWrapper) IsDatabaseAllowed(db string) bool

func (*NamespaceWrapper) IsDeniedSQL

func (n *NamespaceWrapper) IsDeniedSQL(sqlFeature uint32) bool

func (*NamespaceWrapper) ListDatabases

func (n *NamespaceWrapper) ListDatabases() []string

func (*NamespaceWrapper) Name

func (n *NamespaceWrapper) Name() string

type SQLInfo

type SQLInfo struct {
	SQL string
}

type StrategySlice

type StrategySlice []config.StrategyInfo

func (StrategySlice) Len

func (a StrategySlice) Len() int

func (StrategySlice) Less

func (a StrategySlice) Less(i, j int) bool

func (StrategySlice) Swap

func (a StrategySlice) Swap(i, j int)

type UserNamespaceMapper

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

func CreateUserNamespaceMapper

func CreateUserNamespaceMapper(namespaces []*config.Namespace) (*UserNamespaceMapper, error)

func (*UserNamespaceMapper) AddNamespaceUsers

func (u *UserNamespaceMapper) AddNamespaceUsers(ns string, cfg *config.FrontendNamespace) error

func (*UserNamespaceMapper) Clone

func (*UserNamespaceMapper) GetUserNamespace

func (u *UserNamespaceMapper) GetUserNamespace(username string) (string, bool)

func (*UserNamespaceMapper) RemoveNamespaceUsers

func (u *UserNamespaceMapper) RemoveNamespaceUsers(ns string)

Jump to

Keyboard shortcuts

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