registry

package
v0.5.24 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRegistrarName

func GetRegistrarName(cfg config.Config) string

func Register

func Register(factory Factory)

Register 添加注册中心工厂对象

Types

type Factory

type Factory interface {
	Name() string
	Create(config.Config) (Registrar, error)
}

IFactory 注册中心构建器

type Registrar

type Registrar interface {
	Name() string

	ServerConfigs() string
	// Register the registration.
	Register(ctx context.Context, service *ServiceInstance) error
	// Deregister the registration.
	Deregister(ctx context.Context, service *ServiceInstance) error

	// 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)

	// GetAllServicesInfo return all services in memory.
	GetAllServicesInfo(ctx context.Context) (ServiceList, error)

	// GetImpl return the implementation of the registrar.
	GetImpl() any
}

Registrar is service registrar.

func GetRegistrar

func GetRegistrar(cfg config.Config) (Registrar, error)

type ServerItem added in v0.1.1

type ServerItem struct {
	ServiceName string
	EndpointURL string //scheme://host:port/path
}

type ServiceInstance

type ServiceInstance struct {
	ID       string            `json:"id"`
	Name     string            `json:"name"`
	Version  string            `json:"version"`
	Metadata map[string]string `json:"metadata"`
	//http://localhost:8000
	Endpoints []ServerItem `json:"endpoints"`
}

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

type ServiceList added in v0.5.7

type ServiceList struct {
	Count    int64    `json:"count"`
	NameList []string `json:"name_list"`
}

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