registry

package
v0.0.0-...-9eed78a Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 3 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 {
	// GetService return the service instances in memory according to the service name.
	GetService(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
	// Watch creates a watcher according to the service name.
	Watch(ctx context.Context, serviceName string) (Watcher, error)
}

Discovery is service discovery.

type Registrar

type Registrar interface {
	// Register a service instance.
	Register(ctx context.Context, service *ServiceInstance) error
	// Deregister a service instance.
	Deregister(ctx context.Context, service *ServiceInstance) error
}

Registrar is service registrar.

type ServiceInstance

type ServiceInstance struct {
	ID        string            `json:"id"`        // the unique instance ID as registered
	Name      string            `json:"name"`      // the service Name as registered
	Version   string            `json:"version"`   // the version of the compiled
	Metadata  map[string]string `json:"metadata"`  // the kv pair metadata associated with the service instance
	Endpoints []string          `json:"endpoints"` // Endpoints: the addresses of service instance
}

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

func (*ServiceInstance) Equals

func (i *ServiceInstance) Equals(rhs any) bool

func (*ServiceInstance) String

func (i *ServiceInstance) String() string

type Watcher

type Watcher interface {
	// Next 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)
	// Stop close the watcher.
	Stop() error
}

Watcher is service watcher.

Jump to

Keyboard shortcuts

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