版本Sarama - v1.32.0Kafka - 5.4.6-2.12Go - v1.16.2sarama.Logger = log.New(os.Stderr, "[Sarama] ", log.LstdFlags)brokers := []string{ "kafka1:9092", "kafka2:9092",}cfg := sarama.NewConfig()cfg.Version = sarama.V2_4_0_0admin, err := sarama.NewClusterAdmin(brokers, sarama.NewConfig())if err != nil { log.Fatal(err)}brok, _, err := admin.DescribeCluster()if err != nil { log.Fatal(err)}for _, b := range brok { chck, err := b.Connected() if err != nil { log.Fatal(err) } log.Println(chck)}我正在尝试检查代理是否已连接,但它为方法 Connected() 返回 false。如果有关于为什么它返回 false 的解释?我需要写一份健康检查,所以我最初的计划是检查经纪人是否已连接,但我可以做其他检查吗?saramaConfig := sarama.NewConfig()saramaConfig.Version = sarama.V2_0_0_0client, err := sarama.NewClient(brokers, saramaConfig)if err != nil { log.Fatal("NewKafkaAdmin", fmt.Sprintf(`cannot get controller - %+v`, err))}b, _ := client.Controller()fmt.Println(b.Connected())这返回真。为什么会有这样的不匹配?
添加回答
举报
0/150
提交
取消