Skip to content
This repository has been archived by the owner on May 30, 2024. It is now read-only.

Commit

Permalink
Shorter timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Mick Staugaard committed Jun 11, 2020
1 parent 9a0d5c5 commit ca535a2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cmd/createTopic.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"
"os"
"strings"

"github.com/Shopify/sarama"
Expand Down Expand Up @@ -32,7 +33,7 @@ kafkaCLI createTopic --bootstrap-server kafka:9092 --partitions 4 --replication-
}

if ifNotExists {
fmt.Println(err)
fmt.Fprintln(os.Stderr, err)
} else {
panic(err)
}
Expand Down
7 changes: 5 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ func init() {
func kafkaClient() sarama.Client {
kafkaConfig := sarama.NewConfig()
kafkaConfig.Version = sarama.V1_0_0_0
kafkaConfig.Net.ReadTimeout = 5 * time.Second
kafkaConfig.Net.DialTimeout = 5 * time.Second
kafkaConfig.Net.WriteTimeout = 5 * time.Second
addresses := []string{bootstrapServer}

var client sarama.Client
Expand All @@ -45,7 +48,7 @@ func kafkaClient() sarama.Client {
break
}

fmt.Println("failed to connect to " + bootstrapServer + " Retrying in 1s")
fmt.Fprintln(os.Stderr, "failed to connect to "+bootstrapServer+" Retrying in 1s")
time.Sleep(time.Second)
}

Expand All @@ -68,7 +71,7 @@ func kafkaAdmin() sarama.ClusterAdmin {
break
}

fmt.Println("failed to admin cluster at " + bootstrapServer + " Retrying in 1s")
fmt.Fprintln(os.Stderr, "failed to admin cluster at "+bootstrapServer+" Retrying in 1s")
time.Sleep(time.Second)
}

Expand Down

0 comments on commit ca535a2

Please sign in to comment.