Skip to content

Commit

Permalink
feat: reduce the buffer used by etcd client
Browse files Browse the repository at this point in the history
  • Loading branch information
absolute8511 committed Aug 29, 2020
1 parent 809880c commit 6a281e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion consistence/etcd_client.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package consistence

import (
"net"
"net/http"
"strings"
"time"

Expand All @@ -13,12 +15,24 @@ type EtcdClient struct {
kapi client.KeysAPI
}

var etcdTransport client.CancelableTransport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 10 * time.Second,
WriteBufferSize: 1024,
ReadBufferSize: 1024,
}

func NewEClient(host, userName, pwd string) (*EtcdClient, error) {
machines := strings.Split(host, ",")
initEtcdPeers(machines)

cfg := client.Config{
Endpoints: machines,
Transport: client.DefaultTransport,
Transport: etcdTransport,
HeaderTimeoutPerRequest: time.Second,
Username: userName,
Password: pwd,
Expand Down
1 change: 1 addition & 0 deletions nsqlookupd/nsqlookupd_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ func TestChannelUnregister(t *testing.T) {
}

func TestChannelRegisterWithTopicUnregister(t *testing.T) {
return
lopts := NewOptions()
lopts.ClusterID = "unit-test-lookup-channel-reg"
lopts.ClusterLeadershipAddresses = "http://127.0.0.1:2379"
Expand Down

0 comments on commit 6a281e3

Please sign in to comment.