Documentation ¶
Index ¶
- type FuncOps
- type NameAdaptor
- type ServiceDiscovery
- func (sd *ServiceDiscovery) Close()
- func (sd *ServiceDiscovery) QueryForInstances(k8sServiceName string) ([]ServiceInstance, error)
- func (sd *ServiceDiscovery) QueryForNames() ([]string, error)
- func (sd *ServiceDiscovery) RegisterService(instance ServiceInstance) error
- func (sd *ServiceDiscovery) UnregisterService(instance ServiceInstance) error
- type ServiceInstance
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 }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.