Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: 🍻 增加zk插件timeout配置项的默认值 #1023

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions inputs/zookeeper/zookeeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package zookeeper
import (
crypto_tls "crypto/tls"
"fmt"
"io/ioutil"
"io"
"log"
"net"
"regexp"
Expand All @@ -26,7 +26,7 @@ const (
)

var (
versionRE = regexp.MustCompile(`^([0-9]+\.[0-9]+\.[0-9]+).*$`)
versionRE = regexp.MustCompile(` ^ ([0-9]+\.[0-9]+\.[0-9]+).*$`)
eryajf marked this conversation as resolved.
Show resolved Hide resolved
metricNameReplacer = strings.NewReplacer("-", "_", ".", "_")
)

Expand Down Expand Up @@ -91,6 +91,10 @@ func (ins *Instance) Init() error {
if len(ins.ZkHosts()) == 0 {
return types.ErrInstancesEmpty
}
// set default timeout
if ins.Timeout == 0 {
ins.Timeout = 10
}
return nil
}

Expand Down Expand Up @@ -242,7 +246,7 @@ func sendZookeeperCmd(conn net.Conn, cmd string) string {
return ""
}

res, err := ioutil.ReadAll(conn)
res, err := io.ReadAll(conn)
if err != nil {
log.Printf("E! failed read Zookeeper command: '%s' response from '%s': %s", cmd, conn.RemoteAddr().String(), err)
return ""
Expand Down