discovery

package
v0.2.10-29 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWatcherStopped = errors.New("watcher stopped")

ErrWatcherStopped Watcher stopped error when watcher is stopped

Functions

This section is empty.

Types

type Config

type Config struct {
	RegisterInterval time.Duration          `yaml:"registerInterval"`
	Driver           string                 `json:"driver" yaml:"driver"`
	DriverCfg        map[string]interface{} `json:"driver_config" yaml:"driver_config"`
}

func (*Config) Check

func (cfg *Config) Check() *Config

type Discovery

type Discovery interface {
	String() string
	Watch(ctx context.Context, srv string, opts ...WatchOpt) result.Result[Watcher]
	GetService(ctx context.Context, srv string, opts ...GetOpt) result.Result[[]*service.Service]
}

type GetOpt

type GetOpt func(*GetOpts)

type GetOpts

type GetOpts struct {
	Timeout time.Duration
}

type Result

type Result struct {
	Action  eventpbv1.EventType
	Service *service.Service
}

Result is returned by a call to Next on the watcher. Actions can be create, update, delete

type ServiceInstance

type ServiceInstance struct {
	// ID is the unique instance ID as registered.
	ID string `json:"id"`
	// Name is the service name as registered.
	Name string `json:"name"`
	// Version is the version of the compiled.
	Version string `json:"version"`
	// Metadata is the kv pair metadata associated with the service instance.
	Metadata map[string]string `json:"metadata"`
	// Endpoints are 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 `json:"endpoints"`
}

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

type WatchOpt

type WatchOpt func(*WatchOpts)

type WatchOpts

type WatchOpts struct {
	Service string
}

type Watcher

type Watcher interface {
	// Next is a blocking call
	Next() result.Result[*Result]
	Stop() error
}

Watcher is an interface that returns updates about services within the registry.

Jump to

Keyboard shortcuts

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