curator_discovery

package
v3.0.0-rc4 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2021 License: Apache-2.0 Imports: 11 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Entry contain a service instance

type ServiceDiscovery

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

ServiceInstance which define in curator-x-discovery, please refer to https://github.com/apache/curator/blob/master/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceDiscovery.java It's not exactly the same as curator-x-discovery's service discovery

func NewServiceDiscovery

func NewServiceDiscovery(client *gxzookeeper.ZookeeperClient, basePath string) *ServiceDiscovery

NewServiceDiscovery the constructor of service discovery

func (*ServiceDiscovery) Close

func (sd *ServiceDiscovery) Close()

func (*ServiceDiscovery) DataChange

func (sd *ServiceDiscovery) DataChange(eventType remoting.Event) bool

DataChange implement DataListener's DataChange function

func (*ServiceDiscovery) ListenServiceEvent

func (sd *ServiceDiscovery) ListenServiceEvent(name string, listener remoting.DataListener)

ListenServiceEvent add a listener in a service

func (*ServiceDiscovery) ListenServiceInstanceEvent

func (sd *ServiceDiscovery) ListenServiceInstanceEvent(name, id string, listener remoting.DataListener)

ListenServiceEvent add a listener in a instance

func (*ServiceDiscovery) QueryForInstance

func (sd *ServiceDiscovery) QueryForInstance(name string, id string) (*ServiceInstance, error)

QueryForInstance query instances in zookeeper by name and id

func (*ServiceDiscovery) QueryForInstances

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

QueryForInstances query instances in zookeeper by name

func (*ServiceDiscovery) QueryForNames

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

QueryForInstance query all service name in zookeeper

func (*ServiceDiscovery) ReRegisterServices

func (sd *ServiceDiscovery) ReRegisterServices()

ReRegisterServices re-register all cache services to 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

func (*ServiceDiscovery) UpdateService

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

UpdateService update service in zookeeper, and ensure cache is consistent with zookeeper

type ServiceInstance

type ServiceInstance struct {
	Name                string      `json:"name,omitempty"`
	ID                  string      `json:"id,omitempty"`
	Address             string      `json:"address,omitempty"`
	Port                int         `json:"port,omitempty"`
	Payload             interface{} `json:"payload,omitempty"`
	RegistrationTimeUTC int64       `json:"registrationTimeUTC,omitempty"`
}

ServiceInstance which define in curator-x-discovery, please refer to https://github.com/apache/curator/blob/master/curator-x-discovery/src/main/java/org/apache/curator/x/discovery/ServiceInstance.java

Jump to

Keyboard shortcuts

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