register

package
v0.1.23 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: Apache-2.0 Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Marshal

func Marshal(s *ServiceInstance) (string, error)

Types

type IDiscovery

type IDiscovery interface {
	GetService(ctx context.Context, serviceName string) ([]*ServiceInstance, error)
	// Watch creates a watcher according to the service name.
	Watch(ctx context.Context, serviceName string) (IWatcher, error)
}

IDiscovery 服务发现

type IRegister

type IRegister interface {
	Register(ctx context.Context, service *ServiceInstance) error
	Deregister(ctx context.Context, service *ServiceInstance) error
}

IRegister 服务注册

type IWatcher

type IWatcher 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
}

type ServiceInstance

type ServiceInstance struct {
	Name     string `json:"name"`
	Key      string `json:"key"`
	Endpoint string `json:"endpoint"`
}

func NewServiceInstance

func NewServiceInstance(id int64, nameSpace, name, endpoint string) *ServiceInstance

func Unmarshal

func Unmarshal(data []byte) (s *ServiceInstance, err error)

func (*ServiceInstance) GetServerName

func (s *ServiceInstance) GetServerName() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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