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