registry

package
v2.0.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2021 License: MIT Imports: 0 Imported by: 275

README

Registry

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Registry

type Registry interface {
	// Register the registration.
	Register(service *ServiceInstance) error
	// Deregister the registration.
	Deregister(service *ServiceInstance) error
	// Service return the service instances in memory according to the service name.
	Service(name string) ([]*ServiceInstance, error)
	// Watch creates a watcher according to the service name.
	Watch(name string) (Watcher, error)
}

Registry is service registry.

type ServiceInstance

type ServiceInstance struct {
	// ID is the unique instance ID as registered.
	ID string
	// Name is the service name as registered.
	Name string
	// Version is the version of the compiled.
	Version string
	// Metadata is the kv pair metadata associated with the service instance.
	Metadata map[string]string
	// Endpoints is endpoint addresses of the service instance.
	// schema:
	//   http://127.0.0.1:8000?isSecure=false
	//   grpc://127.0.0.1:9000?isSecure=false
	Endpoints []string
}

ServiceInstance is an instance of a service in a discovery system.

type Watcher

type Watcher interface {
	// Watch returns services in the following two cases:
	// 1.the first time to watch and the service instance list is not empty.
	// 2.any service instance changes found.
	// if the above two conditions are not met, it will block until context deadline exceeded or canceled
	Next() ([]*ServiceInstance, error)
	// Close close the watcher.
	Close() error
}

Watcher is service watcher.

Jump to

Keyboard shortcuts

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