You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
655 B

This file contains ambiguous Unicode characters!

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)
}