servicediscovery

package
v1.0.0-rc3 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ServiceDiscovery

type ServiceDiscovery interface {

	// QueryAllServices get all service from remote registry center
	QueryAllServices() ([]ServiceInstance, error)

	// QueryServicesByName get service by serviceName from remote registry center
	QueryServicesByName(serviceNames []string) ([]ServiceInstance, error)

	// Register register to remote registry center
	Register() error

	// UnRegister unregister to remote registry center
	UnRegister() error

	// Subscribe subscribe the service event from remote registry center
	Subscribe() error

	// Unsubscribe unsubscribe from remote registry center
	Unsubscribe() error
}

type ServiceEventListener

type ServiceEventListener interface {
	OnAddServiceInstance(r *ServiceInstance)
	OnDeleteServiceInstance(r *ServiceInstance)
	OnUpdateServiceInstance(r *ServiceInstance)
	GetServiceNames() []string
}

type ServiceInstance

type ServiceInstance struct {
	ID          string
	ServiceName string
	// host:port
	Host        string
	Port        int
	Healthy     bool
	CLusterName string
	Enable      bool
	// extra info such as label or other meta data
	Metadata map[string]string
}

ServiceInstance the service instance info fetched from registry such as nacos consul

func (*ServiceInstance) GetUniqKey

func (i *ServiceInstance) GetUniqKey() string

func (*ServiceInstance) ToEndpoint

func (i *ServiceInstance) ToEndpoint() *model.Endpoint

ToEndpoint

func (*ServiceInstance) ToRoute

func (i *ServiceInstance) ToRoute() *model.Router

ToRoute route ID is cluster name, so equal with endpoint name and routerMatch prefix is also service name

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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