This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
package main
import (
"github.com/Shopify/sarama"
"log"
)
func main() {
// 一,得到异步的producer
brokers := []string{"localhost:9092"}
conf := sarama.NewConfig()
// 1, default
conf.Producer.RequiredAcks = sarama.WaitForLocal
// -1
conf.Producer.RequiredAcks = sarama.WaitForAll
// 0
conf.Producer.RequiredAcks = sarama.NoResponse
producer, err := sarama.NewAsyncProducer(brokers, conf)
if err != nil {
log.Fatalln(err)
}
// 通常还要配合
// 未同步的follower是否可以选举为leader
//unclean.leader.election.enable = false
// 最小的正常同步状态的 follower 数量
//min.insync.replicas = $(N/2 + 1)