From 56ec64c7095db722d8430ccdfd57ba59212fd42e Mon Sep 17 00:00:00 2001 From: Gordon <46924906+FGadvancer@users.noreply.github.com> Date: Thu, 26 Oct 2023 10:57:29 +0800 Subject: [PATCH] feat: change close function to interface Adapting for Kubernetes --- discoveryregistry/discovery_register.go | 1 + discoveryregistry/zookeeper/zk.go | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/discoveryregistry/discovery_register.go b/discoveryregistry/discovery_register.go index 69509a6..4ac4ad9 100644 --- a/discoveryregistry/discovery_register.go +++ b/discoveryregistry/discovery_register.go @@ -37,4 +37,5 @@ type SvcDiscoveryRegistry interface { CreateRpcRootNodes(serviceNames []string) error RegisterConf2Registry(key string, conf []byte) error GetConfFromRegistry(key string) ([]byte, error) + Close() } diff --git a/discoveryregistry/zookeeper/zk.go b/discoveryregistry/zookeeper/zk.go index e9ea455..1c9917b 100644 --- a/discoveryregistry/zookeeper/zk.go +++ b/discoveryregistry/zookeeper/zk.go @@ -137,7 +137,7 @@ func NewClient(zkServers []string, zkRoot string, options ...ZkOption) (*ZkClien client.eventChan = eventChan client.conn = conn if err := client.ensureRoot(); err != nil { - client.CloseZK() + client.Close() return nil, err } resolver.Register(client) @@ -147,7 +147,7 @@ func NewClient(zkServers []string, zkRoot string, options ...ZkOption) (*ZkClien return client, nil } -func (s *ZkClient) CloseZK() { +func (s *ZkClient) Close() { s.logger.Printf("close zk called") s.cancel() s.ticker.Stop()