Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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
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
NewInstance creates a new service instance with the given address and weight.
func (*Instance) Tag ¶ added in v0.4.0
Tag retrieves a specific metadata tag value from 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.