servicegovernance

package
v0.0.0-...-11ea465 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultGroup = "default"
)

Variables

This section is empty.

Functions

func RegisterETCD

func RegisterETCD(endpoints []string, envName, serviceName, address string) error

Types

type DiscoverNamingService

type DiscoverNamingService func(etcdEndpoints []string, envName, serviceName, group string, watchEnabled bool) ([]*Endpoint, error)

type Discoverer

type Discoverer interface {
	Get(ctx context.Context, serviceKeyPrefix string) ([]*Endpoint, error)
	Watch(ctx context.Context, serviceKeyPrefix string) ([]*Endpoint, Watcher, error)
}

func NewEtcdDiscoverer

func NewEtcdDiscoverer(cli *clientv3.Client) Discoverer

type Endpoint

type Endpoint struct {
	Address  string              `json:"address"`
	Group    string              `json:"group"`
	Metadata map[string][]string `json:"metadata"`
}

func DiscoverETCD

func DiscoverETCD(etcdEndpoints []string, envName, serviceName, group string, watchEnabled bool) ([]*Endpoint, error)

func FilterOrDefault

func FilterOrDefault(endpoints []*Endpoint, group string) []*Endpoint

func (*Endpoint) Decode

func (e *Endpoint) Decode(value []byte) error

func (*Endpoint) Encode

func (e *Endpoint) Encode() string

type Instance

type Instance struct {
	Env         string
	ServiceName string
	Endpoint    Endpoint
}

func (*Instance) Key

func (i *Instance) Key() string

func (*Instance) ServiceWithEnv

func (i *Instance) ServiceWithEnv() string

type RegisterNamingService

type RegisterNamingService func(endpoints []string, env, service, address string) error

type Registrar

type Registrar interface {
	Register(ctx context.Context, instance *Instance) error
	Deregister(ctx context.Context) error
}

func NewEtcdRegistry

func NewEtcdRegistry(cli *clientv3.Client) Registrar

type Watcher

type Watcher interface {
	Service() string
	Next() ([]*Endpoint, error)
	Close() error
}

Jump to

Keyboard shortcuts

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