Help us shape the future of Go! Take the 2026 Go Developer Survey

provider

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWatchNotSupported = errors.New("watch is not supported")

ErrWatchNotSupported is returned when a service discovery provider does not support watching.

Functions

This section is empty.

Types

type ChangeFunc

type ChangeFunc func() error

ChangeFunc is a function that is called when configuration changes.

type DiscoveryResult added in v0.11.0

type DiscoveryResult struct {
	Target string            // hostname:port (from config TargetOptions.Target, or discovery service name)
	Weight uint32            // target-level weight
	Tags   map[string]string // target-level tags
	Nodes  []Instancer       // resolved instances for this target
}

DiscoveryResult preserves the target→instances grouping from discovery.

type GetInstanceOptions added in v0.4.0

type GetInstanceOptions struct {
	Namespace string
	Name      string
	Group     string
}

GetInstanceOptions defines the options for retrieving service instances.

type Instance added in v0.4.0

type Instance struct {
	// contains filtered or unexported fields
}

Instance represents a single service instance with an address and metadata.

func NewInstance added in v0.4.0

func NewInstance(addr net.Addr, weight uint32) *Instance

NewInstance creates a new service instance with the given address and weight.

func (*Instance) Address added in v0.4.0

func (i *Instance) Address() net.Addr

Address returns the network address of the instance.

func (*Instance) SetTag added in v0.4.0

func (i *Instance) SetTag(key string, value string)

SetTag sets a metadata tag for the instance.

func (*Instance) Tag added in v0.4.0

func (i *Instance) Tag(key string) (value string, exist bool)

Tag retrieves a specific metadata tag value from the instance.

func (*Instance) Tags added in v0.6.0

func (i *Instance) Tags() map[string]string

Tags returns all metadata tags of the instance.

func (*Instance) Weight added in v0.4.0

func (i *Instance) Weight() uint32

Weight returns the relative weight of the instance.

type Instancer added in v0.4.0

type Instancer interface {
	Address() net.Addr
	Weight() uint32
	Tag(key string) (value string, exist bool)
	Tags() map[string]string
}

Instancer defines the interface for a service instance.

type Provider

type Provider interface {
	Watch() error
	SetOnChanged(f ChangeFunc)
}

Provider defines the interface for configuration providers.

type ServiceDiscovery added in v0.4.0

type ServiceDiscovery interface {
	GetInstances(ctx context.Context, options GetInstanceOptions) ([]DiscoveryResult, error)
	Watch(ctx context.Context, options GetInstanceOptions) (<-chan []DiscoveryResult, error)
	Close() error
}

ServiceDiscovery defines the interface for service discovery.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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