discovery

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2021 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Discovery

type Discovery interface {
	Refresh() error
	Update(servers []string) error
	Get(mode SelectMode) (string, error)
	GetAll() ([]string, error)
}

type GeeRegistryDiscovery

type GeeRegistryDiscovery struct {
	*MultiServersDiscovery // inherit
	// contains filtered or unexported fields
}

func NewGeeRegistryDiscovery

func NewGeeRegistryDiscovery(registryAddr string, timeout time.Duration) *GeeRegistryDiscovery

because of GeeRegistryDiscovery , xclient don't need know the server the GeeRegistryDiscovery will send http Get method to Registry server and refresh alive servers

func (*GeeRegistryDiscovery) Get

func (d *GeeRegistryDiscovery) Get(mode SelectMode) (string, error)

the registry must refresh first and make sure the server is all alive the server is in MultiServersDiscovery.Servers[] so the final get method is on MultiServersDiscovery

func (*GeeRegistryDiscovery) GetAll

func (d *GeeRegistryDiscovery) GetAll() ([]string, error)

func (*GeeRegistryDiscovery) Refresh

func (d *GeeRegistryDiscovery) Refresh() error

func (*GeeRegistryDiscovery) Update

func (d *GeeRegistryDiscovery) Update(servers []string) error

type MultiServersDiscovery

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

MultiServersDiscovery is a discovery for multi servers without a registry center user provides the server addresses explicitly instead

func NewMultiServerDiscovery

func NewMultiServerDiscovery(servers []string) *MultiServersDiscovery

NewMultiServerDiscovery creates a MultiServersDiscovery instance

func (*MultiServersDiscovery) Get

func (d *MultiServersDiscovery) Get(mode SelectMode) (string, error)

get a server according to mode

func (*MultiServersDiscovery) GetAll

func (d *MultiServersDiscovery) GetAll() ([]string, error)

func (*MultiServersDiscovery) Refresh

func (d *MultiServersDiscovery) Refresh() error

no sense for MultiServersDiscovery

func (*MultiServersDiscovery) Update

func (d *MultiServersDiscovery) Update(servers []string) error

Update the servers of discovery dynamically if needed

type SelectMode

type SelectMode int
const (
	RandomSelect SelectMode = iota
	RoundRobinSelect
)

select Mode random and roundrobin

Jump to

Keyboard shortcuts

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