Skip to content

Commit

Permalink
set deadline for kafka client conn (#455)
Browse files Browse the repository at this point in the history
  • Loading branch information
suchen-sci authored Dec 5, 2023
1 parent 6db5f70 commit 62ba269
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions probe/client/kafka/kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"context"
"crypto/tls"
"fmt"
"time"

"github.com/megaease/easeprobe/probe/client/conf"
"github.com/segmentio/kafka-go"
Expand Down Expand Up @@ -85,12 +86,11 @@ func (k *Kafka) Probe() (bool, string) {
defer cancel()

conn, err := dialer.DialContext(ctx, "tcp", k.Host)

if err != nil {
return false, err.Error()
}

defer conn.Close()
conn.SetDeadline(time.Now().Add(k.Timeout()))

partitions, err := conn.ReadPartitions()
if err != nil {
Expand Down

0 comments on commit 62ba269

Please sign in to comment.