@@ -27,40 +27,25 @@ import (
27
27
ab "github.com/hyperledger/fabric/protos/orderer"
28
28
)
29
29
30
- // TODO Set the returned config file to more appropriate
31
- // defaults as we're getting closer to a stable release
32
30
func newBrokerConfig (kafkaVersion sarama.KafkaVersion , chosenStaticPartition int32 , tlsConfig config.TLS ) * sarama.Config {
33
31
brokerConfig := sarama .NewConfig ()
34
32
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
46
34
47
35
brokerConfig .Net .TLS .Enable = tlsConfig .Enabled
48
-
49
36
if brokerConfig .Net .TLS .Enable {
50
37
// create public/private key pair structure
51
38
keyPair , err := tls .X509KeyPair ([]byte (tlsConfig .Certificate ), []byte (tlsConfig .PrivateKey ))
52
39
if err != nil {
53
40
panic (fmt .Errorf ("Unable to decode public/private key pair. Error: %v" , err ))
54
41
}
55
-
56
42
// create root CA pool
57
43
rootCAs := x509 .NewCertPool ()
58
44
for _ , certificate := range tlsConfig .RootCAs {
59
45
if ! rootCAs .AppendCertsFromPEM ([]byte (certificate )) {
60
46
panic (fmt .Errorf ("Unable to decode certificate. Error: %v" , err ))
61
47
}
62
48
}
63
-
64
49
brokerConfig .Net .TLS .Config = & tls.Config {
65
50
Certificates : []tls.Certificate {keyPair },
66
51
RootCAs : rootCAs ,
@@ -69,6 +54,19 @@ func newBrokerConfig(kafkaVersion sarama.KafkaVersion, chosenStaticPartition int
69
54
}
70
55
}
71
56
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
+
72
70
return brokerConfig
73
71
}
74
72
0 commit comments