discovery

package
v1.5.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FuncOps

type FuncOps interface {
	NewInstance(serviceName, instanceId string) ServiceInstance
	PathForService(basePath, serviceName string) (servicePath string)
	PathForInstance(basePath, serviceName, instanceId string) (instancePath string)
	ServiceInstanceId(basePath, instancePath string) (serviceName, instanceId string, err error)
	KtoCName(serviceName string) string
	CToKName(serviceName string) string
}

type NameAdaptor

type NameAdaptor struct {
	C2KNamesCache *expirable.LRU[string, string]
	K2CNamesCache *expirable.LRU[string, string]
}

func (*NameAdaptor) CToKName

func (op *NameAdaptor) CToKName(cName string) string

func (*NameAdaptor) KtoCName

func (op *NameAdaptor) KtoCName(kName string) string

type ServiceDiscovery

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

func NewServiceDiscovery

func NewServiceDiscovery(client *zookeeper.Client, basePath, category string, ops FuncOps) *ServiceDiscovery

NewServiceDiscovery the constructor of service discovery

func (*ServiceDiscovery) Close

func (sd *ServiceDiscovery) Close()

func (*ServiceDiscovery) QueryForInstances

func (sd *ServiceDiscovery) QueryForInstances(k8sServiceName string) ([]ServiceInstance, error)

QueryForInstances query instances in zookeeper by name

func (*ServiceDiscovery) QueryForNames

func (sd *ServiceDiscovery) QueryForNames() ([]string, error)

QueryForNames query all service name in zookeeper

func (*ServiceDiscovery) RegisterService

func (sd *ServiceDiscovery) RegisterService(instance ServiceInstance) error

RegisterService register service to zookeeper, and ensure cache is consistent with zookeeper

func (*ServiceDiscovery) UnregisterService

func (sd *ServiceDiscovery) UnregisterService(instance ServiceInstance) error

UnregisterService un-register service in zookeeper and delete service in cache

type ServiceInstance

type ServiceInstance interface {
	ServiceSchema() string
	ServiceName() string
	ServiceInterface() string
	ServiceMethods() []string
	InstanceId() string

	InstanceIP() string
	InstancePort() int

	Metadatas() map[string]string
	GetMetadata(key string) (string, bool)
	SetMetadata(key, value string) error

	Marshal() ([]byte, error)
	Unmarshal(string, []byte) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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