Skip to content

Commit 42c68c7

Browse files
authoredJan 25, 2025··
Merge pull request #820 from trvrnrth/go-zk
Update to use linkedin/go-zk
2 parents 7e46d70 + 7f97666 commit 42c68c7

File tree

9 files changed

+19
-27
lines changed

9 files changed

+19
-27
lines changed
 

‎NOTICE

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ This product includes/uses eapache/queue (https://github.com/eapache/queue/)
3737
Copyright (c) 2014 Evan Huus
3838
License: MIT
3939

40-
This product includes/uses go-zookeeper (https://github.com/samuel/go-zookeeper/)
40+
This product includes/uses go-zk (https://github.com/linkedin/go-zk/)
4141
Copyright (c) 2013, Samuel Stauffer <samuel@descolada.com>
4242
License: BSD
4343

‎core/internal/consumer/kafka_zk_client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
"sync"
1616
"time"
1717

18-
"github.com/samuel/go-zookeeper/zk"
18+
"github.com/linkedin/go-zk"
1919
"github.com/spf13/viper"
2020
"go.uber.org/zap"
2121

‎core/internal/consumer/kafka_zk_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import (
1717

1818
"github.com/stretchr/testify/assert"
1919

20-
"github.com/samuel/go-zookeeper/zk"
20+
"github.com/linkedin/go-zk"
2121
"github.com/spf13/viper"
2222
"go.uber.org/zap"
2323

‎core/internal/helpers/zookeeper.go

+10-19
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ package helpers
1212
import (
1313
"crypto/tls"
1414
"crypto/x509"
15-
"net"
1615
"os"
1716
"time"
1817

1918
"github.com/pkg/errors"
2019
"github.com/spf13/viper"
2120

22-
"github.com/samuel/go-zookeeper/zk"
21+
"github.com/linkedin/go-zk"
2322
"github.com/stretchr/testify/mock"
2423
"go.uber.org/zap"
2524

@@ -36,12 +35,7 @@ type BurrowZookeeperClient struct {
3635
// timeout it's possible to reestablish a connection to a different server and keep the same session. This is means any
3736
// ephemeral nodes and watches are maintained.
3837
func ZookeeperConnect(servers []string, sessionTimeout time.Duration, logger *zap.Logger) (protocol.ZookeeperClient, <-chan zk.Event, error) {
39-
// We need a function to set the logger for the ZK connection
40-
zkSetLogger := func(c *zk.Conn) {
41-
c.SetLogger(zap.NewStdLog(logger))
42-
}
43-
44-
zkconn, connEventChan, err := zk.Connect(servers, sessionTimeout, zkSetLogger)
38+
zkconn, connEventChan, err := zk.Connect(servers, sessionTimeout)
4539
return &BurrowZookeeperClient{client: zkconn}, connEventChan, err
4640
}
4741

@@ -57,23 +51,18 @@ func ZookeeperConnectTLS(servers []string, sessionTimeout time.Duration, logger
5751

5852
logger.Info("starting zookeeper (TLS)", zap.String("caFile", caFile), zap.String("certFile", certFile), zap.String("keyFile", keyFile))
5953

60-
dialer, err := newTLSDialer(servers[0], caFile, certFile, keyFile)
54+
dialer, err := newTLSDialer(caFile, certFile, keyFile)
6155
if err != nil {
6256
return nil, nil, err
6357
}
6458

65-
// We need a function to set the logger for the ZK connection
66-
zkSetLogger := func(c *zk.Conn) {
67-
c.SetLogger(zap.NewStdLog(logger))
68-
}
69-
70-
zkconn, connEventChan, err := zk.Connect(servers, sessionTimeout, zk.WithDialer(dialer), zkSetLogger)
59+
zkconn, connEventChan, err := zk.Connect(servers, sessionTimeout, zk.WithDialer(dialer))
7160
return &BurrowZookeeperClient{client: zkconn}, connEventChan, err
7261
}
7362

7463
// newTLSDialer creates a dialer with TLS configured. It will install caFile as root CA and if both certFile and keyFile are
7564
// set, it will add those as a certificate.
76-
func newTLSDialer(addr, caFile, certFile, keyFile string) (zk.Dialer, error) {
65+
func newTLSDialer(caFile, certFile, keyFile string) (zk.Dialer, error) {
7766
caCert, err := os.ReadFile(caFile)
7867
if err != nil {
7968
return nil, errors.New("could not read caFile: " + err.Error())
@@ -96,9 +85,11 @@ func newTLSDialer(addr, caFile, certFile, keyFile string) (zk.Dialer, error) {
9685
tlsConfig.Certificates = []tls.Certificate{cert}
9786
}
9887

99-
return func(string, string, time.Duration) (net.Conn, error) {
100-
return tls.Dial("tcp", addr, tlsConfig)
101-
}, nil
88+
tlsDialer := &tls.Dialer{
89+
Config: tlsConfig,
90+
}
91+
92+
return tlsDialer, nil
10293
}
10394

10495
// Close shuts down the connection to the Zookeeper ensemble.

‎core/internal/zookeeper/coordinator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"sync"
1919
"time"
2020

21-
"github.com/samuel/go-zookeeper/zk"
21+
"github.com/linkedin/go-zk"
2222
"github.com/spf13/viper"
2323
"go.uber.org/zap"
2424

‎core/internal/zookeeper/coordinator_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"github.com/stretchr/testify/assert"
2121
"github.com/stretchr/testify/mock"
2222

23-
"github.com/samuel/go-zookeeper/zk"
23+
"github.com/linkedin/go-zk"
2424
"github.com/spf13/viper"
2525
"go.uber.org/zap"
2626

‎core/protocol/protocol.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ package protocol
1616
import (
1717
"sync"
1818

19-
"github.com/samuel/go-zookeeper/zk"
19+
"github.com/linkedin/go-zk"
2020
"go.uber.org/zap"
2121
)
2222

‎go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ require (
77
github.com/OneOfOne/xxhash v1.2.8
88
github.com/julienschmidt/httprouter v1.3.0
99
github.com/karrick/goswarm v1.10.0
10+
github.com/linkedin/go-zk v0.1.4
1011
github.com/pborman/uuid v1.2.1
1112
github.com/pkg/errors v0.9.1
1213
github.com/prometheus/client_golang v1.20.5

‎go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
6363
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
6464
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
6565
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
66+
github.com/linkedin/go-zk v0.1.4 h1:ZB/u/DaNbHUiuymbtD6C0Bf6s+4O3J36Wqd1Txkztig=
67+
github.com/linkedin/go-zk v0.1.4/go.mod h1:X1Id+YYjM0pt6UHVD0eIUrLkhFL/0rAUn+cvc2EDwhg=
6668
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
6769
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
6870
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM=
@@ -100,8 +102,6 @@ github.com/sagikazarmark/locafero v0.6.0 h1:ON7AQg37yzcRPU69mt7gwhFEBwxI6P9T4Qu3
100102
github.com/sagikazarmark/locafero v0.6.0/go.mod h1:77OmuIc6VTraTXKXIs/uvUxKGUXjE1GbemJYHqdNjX0=
101103
github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
102104
github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
103-
github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414 h1:AJNDS0kP60X8wwWFvbLPwDuojxubj9pbfK7pjHw0vKg=
104-
github.com/samuel/go-zookeeper v0.0.0-20201211165307-7117e9ea2414/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E=
105105
github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
106106
github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
107107
github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=

0 commit comments

Comments
 (0)
Please sign in to comment.