@@ -27,40 +27,25 @@ import (
2727 ab "github.com/hyperledger/fabric/protos/orderer"
2828)
2929
30- // TODO Set the returned config file to more appropriate
31- // defaults as we're getting closer to a stable release
3230func newBrokerConfig (kafkaVersion sarama.KafkaVersion , chosenStaticPartition int32 , tlsConfig config.TLS ) * sarama.Config {
3331 brokerConfig := sarama .NewConfig ()
3432
35- brokerConfig .Version = kafkaVersion
36- // Set the level of acknowledgement reliability needed from the broker.
37- // WaitForAll means that the partition leader will wait till all ISRs
38- // got the message before sending back an ACK to the sender.
39- brokerConfig .Producer .RequiredAcks = sarama .WaitForAll
40- // A partitioner is actually not needed the way we do things now,
41- // but we're adding it now to allow for flexibility in the future.
42- brokerConfig .Producer .Partitioner = newStaticPartitioner (chosenStaticPartition )
43- // Set equivalent of kafka producer config max.request.bytes to the deafult
44- // value of a Kafka broker's socket.request.max.bytes property (100 MiB).
45- brokerConfig .Producer .MaxMessageBytes = int (sarama .MaxRequestSize )
33+ brokerConfig .Consumer .Return .Errors = true
4634
4735 brokerConfig .Net .TLS .Enable = tlsConfig .Enabled
48-
4936 if brokerConfig .Net .TLS .Enable {
5037 // create public/private key pair structure
5138 keyPair , err := tls .X509KeyPair ([]byte (tlsConfig .Certificate ), []byte (tlsConfig .PrivateKey ))
5239 if err != nil {
5340 panic (fmt .Errorf ("Unable to decode public/private key pair. Error: %v" , err ))
5441 }
55-
5642 // create root CA pool
5743 rootCAs := x509 .NewCertPool ()
5844 for _ , certificate := range tlsConfig .RootCAs {
5945 if ! rootCAs .AppendCertsFromPEM ([]byte (certificate )) {
6046 panic (fmt .Errorf ("Unable to decode certificate. Error: %v" , err ))
6147 }
6248 }
63-
6449 brokerConfig .Net .TLS .Config = & tls.Config {
6550 Certificates : []tls.Certificate {keyPair },
6651 RootCAs : rootCAs ,
@@ -69,6 +54,19 @@ func newBrokerConfig(kafkaVersion sarama.KafkaVersion, chosenStaticPartition int
6954 }
7055 }
7156
57+ // Set the level of acknowledgement reliability needed from the broker.
58+ // WaitForAll means that the partition leader will wait till all ISRs
59+ // got the message before sending back an ACK to the sender.
60+ brokerConfig .Producer .RequiredAcks = sarama .WaitForAll
61+ // A partitioner is actually not needed the way we do things now,
62+ // but we're adding it now to allow for flexibility in the future.
63+ brokerConfig .Producer .Partitioner = newStaticPartitioner (chosenStaticPartition )
64+ // Set equivalent of Kafka producer config max.request.bytes to the default
65+ // value of a Kafka broker's socket.request.max.bytes property (100 MiB).
66+ brokerConfig .Producer .MaxMessageBytes = int (sarama .MaxRequestSize )
67+
68+ brokerConfig .Version = kafkaVersion
69+
7270 return brokerConfig
7371}
7472
0 commit comments