Documentation
¶
Index ¶
- Variables
- func Bind(conf interface{}, sep ...string) error
- func RegisterStore(st Storage)
- func Subscribe(conf interface{}, key string, b bindKeyUpdater) error
- func Supervisor(interval time.Duration)
- func Unsubscribe(conf interface{}, key string, b bindKeyUpdater) error
- func WrapConf(conf interface{}, tagName string, pathSeparator rune) bindUpdater
- type Balancer
- type BindHeap
- func (bh *BindHeap) Bind(conf interface{}, sep ...string) error
- func (bh *BindHeap) RegisterStore(st Storage)
- func (bh *BindHeap) Subscribe(conf interface{}, key string, b bindKeyUpdater) error
- func (bh *BindHeap) Supervisor(interval time.Duration)
- func (bh *BindHeap) Unsubscribe(conf interface{}, key string, b bindKeyUpdater) error
- type Connect
- type Storage
- type Upstream
- type UpstreamServiceItem
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUnbindedConfig = errors.New("Config is not bind") ErrInvalidKeyParam = errors.New("Invalid key params") ErrInvalidTargetStruct = errors.New("Invalid bind target struct") )
Errors set
Functions ¶
func Unsubscribe ¶
Unsubscribe updater for config
Types ¶
type Balancer ¶
type Balancer interface {
// Borrow service from upstream
Borrow(service string) Connect
// Return connect back to pool
Return(conn Connect, errResult error)
// Refresh current state
Refresh() error
// Supervisor loop
Supervisor(interval time.Duration)
// Stop supervisor
Stop()
}
Balancer of service
type BindHeap ¶
type BindHeap struct {
// contains filtered or unexported fields
}
BindHeap base type
var (
DefaultBindHeap BindHeap
)
Global vars
func (*BindHeap) RegisterStore ¶
RegisterStore in heap
func (*BindHeap) Supervisor ¶
Supervisor of auto refresh
func (*BindHeap) Unsubscribe ¶
Unsubscribe updater for config
type Storage ¶
type Storage interface {
// Subscribe config key updater
Subscribe(f func(key string, value interface{}))
// Discovery services
Discovery() service.Discovery
// Supervisor of auto refresh
Supervisor(interval time.Duration)
}
Storage connector
type Upstream ¶
type Upstream struct {
// contains filtered or unexported fields
}
Upstream connection queue
type UpstreamServiceItem ¶
type UpstreamServiceItem struct {
Service *service.Service
Upstream *Upstream
// contains filtered or unexported fields
}
UpstreamServiceItem wrapper
func UpstreamService ¶
func UpstreamService(srv *service.Service) *UpstreamServiceItem
UpstreamService wrapper function
func (*UpstreamServiceItem) Connect ¶
func (it *UpstreamServiceItem) Connect(up *Upstream) Connect
Connect service interface
func (*UpstreamServiceItem) Return ¶
func (it *UpstreamServiceItem) Return(resultError error)
Return service to upstream pool
func (*UpstreamServiceItem) SetWeight ¶
func (it *UpstreamServiceItem) SetWeight(weight int)
SetWeight of service
Source Files
¶
Click to show internal directories.
Click to hide internal directories.