servicediscovery

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoEndpoints = errors.New("no endpoints available")

ErrNoEndpoints is returned when no qualifying endpoints are available.

Functions

This section is empty.

Types

type Balancer

type Balancer interface {
	Next(serviceName string) (ServiceInstance, error)
}

Balancer yields endpoints according to some heuristic.

type DefaultServiceInstance

type DefaultServiceInstance struct {
	Id          string
	ServiceName string
	Host        string
	Port        uint64
	ClusterName string
	GroupName   string
	Tags        []string
	Enable      bool
	Healthy     bool
	Weight      float64
	Metadata    map[string]string
}

DefaultServiceInstance the default implementation of ServiceInstance or change the ServiceInstance to be struct???

func (*DefaultServiceInstance) GetClusterName

func (d *DefaultServiceInstance) GetClusterName() string

func (*DefaultServiceInstance) GetGroupName

func (d *DefaultServiceInstance) GetGroupName() string

func (*DefaultServiceInstance) GetHost

func (d *DefaultServiceInstance) GetHost() string

GetHost will return the hostname

func (*DefaultServiceInstance) GetId

func (d *DefaultServiceInstance) GetId() string

GetId will return this instance's id. It should be unique.

func (*DefaultServiceInstance) GetMetadata

func (d *DefaultServiceInstance) GetMetadata() map[string]string

GetMetadata will return the metadata, it will never return nil

func (*DefaultServiceInstance) GetPort

func (d *DefaultServiceInstance) GetPort() uint64

GetPort will return the port.

func (*DefaultServiceInstance) GetServiceName

func (d *DefaultServiceInstance) GetServiceName() string

GetServiceName will return the serviceName

func (*DefaultServiceInstance) GetTags

func (d *DefaultServiceInstance) GetTags() []string

func (*DefaultServiceInstance) GetWeight

func (d *DefaultServiceInstance) GetWeight() float64

func (*DefaultServiceInstance) IsEnable

func (d *DefaultServiceInstance) IsEnable() bool

IsEnable will return the enable status of this instance

func (*DefaultServiceInstance) IsHealthy

func (d *DefaultServiceInstance) IsHealthy() bool

IsHealthy will return the value represent the instance whether healthy or not

type IServiceDiscovery

type IServiceDiscovery interface {
	GetName() string
	Register() error
	Update() error
	Unregister() error
	GetHealthyInstances(serviceName string) []ServiceInstance
	GetAllInstances(serviceName string) []ServiceInstance
	Destroy() error
}

type ServiceInstance

type ServiceInstance interface {

	// GetId will return this instance's id. It should be unique.
	GetId() string

	// GetServiceName will return the serviceName
	GetServiceName() string

	// GetHost will return the hostname
	GetHost() string

	// GetPort will return the port.
	GetPort() uint64

	GetWeight() float64

	GetTags() []string

	GetClusterName() string

	GetGroupName() string

	// IsEnable will return the enable status of this instance
	IsEnable() bool

	// IsHealthy will return the value represent the instance whether healthy or not
	IsHealthy() bool

	// GetMetadata will return the metadata
	GetMetadata() map[string]string
}

ServiceInstance is the model class of an instance of a service, which is used for service registration and discovery.

Jump to

Keyboard shortcuts

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