@@ -29,50 +29,51 @@ import (
29
29
)
30
30
31
31
// New creates a Kafka-backed consenter. Called by orderer's main.go.
32
- func New (kv sarama.KafkaVersion , ro config.Retry ) multichain.Consenter {
33
- return newConsenter (kv , ro , bfValue , pfValue , cfValue )
32
+ func New (kv sarama.KafkaVersion , ro config.Retry , tls config. TLS ) multichain.Consenter {
33
+ return newConsenter (kv , ro , tls , bfValue , pfValue , cfValue )
34
34
}
35
35
36
36
// New calls here because we need to pass additional arguments to
37
37
// the constructor and New() should only read from the config file.
38
- func newConsenter (kv sarama.KafkaVersion , ro config.Retry , bf bfType , pf pfType , cf cfType ) multichain.Consenter {
39
- return & consenterImpl {kv , ro , bf , pf , cf }
38
+ func newConsenter (kv sarama.KafkaVersion , ro config.Retry , tls config. TLS , bf bfType , pf pfType , cf cfType ) multichain.Consenter {
39
+ return & consenterImpl {kv , ro , tls , bf , pf , cf }
40
40
}
41
41
42
42
// bfType defines the signature of the broker constructor.
43
43
type bfType func ([]string , ChainPartition ) (Broker , error )
44
44
45
45
// pfType defines the signature of the producer constructor.
46
- type pfType func ([]string , sarama.KafkaVersion , config.Retry ) Producer
46
+ type pfType func ([]string , sarama.KafkaVersion , config.Retry , config. TLS ) Producer
47
47
48
48
// cfType defines the signature of the consumer constructor.
49
- type cfType func ([]string , sarama.KafkaVersion , ChainPartition , int64 ) (Consumer , error )
49
+ type cfType func ([]string , sarama.KafkaVersion , config. TLS , ChainPartition , int64 ) (Consumer , error )
50
50
51
51
// bfValue holds the value for the broker constructor that's used in the non-test case.
52
52
var bfValue = func (brokers []string , cp ChainPartition ) (Broker , error ) {
53
53
return newBroker (brokers , cp )
54
54
}
55
55
56
56
// pfValue holds the value for the producer constructor that's used in the non-test case.
57
- var pfValue = func (brokers []string , kafkaVersion sarama.KafkaVersion , retryOptions config.Retry ) Producer {
58
- return newProducer (brokers , kafkaVersion , retryOptions )
57
+ var pfValue = func (brokers []string , kafkaVersion sarama.KafkaVersion , retryOptions config.Retry , tls config. TLS ) Producer {
58
+ return newProducer (brokers , kafkaVersion , retryOptions , tls )
59
59
}
60
60
61
61
// cfValue holds the value for the consumer constructor that's used in the non-test case.
62
- var cfValue = func (brokers []string , kafkaVersion sarama.KafkaVersion , cp ChainPartition , offset int64 ) (Consumer , error ) {
63
- return newConsumer (brokers , kafkaVersion , cp , offset )
62
+ var cfValue = func (brokers []string , kafkaVersion sarama.KafkaVersion , tls config. TLS , cp ChainPartition , offset int64 ) (Consumer , error ) {
63
+ return newConsumer (brokers , kafkaVersion , tls , cp , offset )
64
64
}
65
65
66
66
// consenterImpl holds the implementation of type that satisfies the
67
67
// multichain.Consenter and testableConsenter interfaces. The former
68
68
// is needed because that is what the HandleChain contract requires.
69
69
// The latter is needed for testing.
70
70
type consenterImpl struct {
71
- kv sarama.KafkaVersion
72
- ro config.Retry
73
- bf bfType
74
- pf pfType
75
- cf cfType
71
+ kv sarama.KafkaVersion
72
+ ro config.Retry
73
+ tls config.TLS
74
+ bf bfType
75
+ pf pfType
76
+ cf cfType
76
77
}
77
78
78
79
// HandleChain creates/returns a reference to a Chain for the given set of support resources.
@@ -110,7 +111,7 @@ func newChain(consenter testableConsenter, support multichain.ConsenterSupport,
110
111
partition : newChainPartition (support .ChainID (), rawPartition ),
111
112
batchTimeout : support .SharedConfig ().BatchTimeout (),
112
113
lastOffsetPersisted : lastOffsetPersisted ,
113
- producer : consenter .prodFunc ()(support .SharedConfig ().KafkaBrokers (), consenter .kafkaVersion (), consenter .retryOptions ()),
114
+ producer : consenter .prodFunc ()(support .SharedConfig ().KafkaBrokers (), consenter .kafkaVersion (), consenter .retryOptions (), consenter . tlsConfig () ),
114
115
halted : false , // Redundant as the default value for booleans is false but added for readability
115
116
exitChan : make (chan struct {}),
116
117
haltedChan : make (chan struct {}),
@@ -123,13 +124,15 @@ func newChain(consenter testableConsenter, support multichain.ConsenterSupport,
123
124
type testableConsenter interface {
124
125
kafkaVersion () sarama.KafkaVersion
125
126
retryOptions () config.Retry
127
+ tlsConfig () config.TLS
126
128
brokFunc () bfType
127
129
prodFunc () pfType
128
130
consFunc () cfType
129
131
}
130
132
131
133
func (co * consenterImpl ) kafkaVersion () sarama.KafkaVersion { return co .kv }
132
134
func (co * consenterImpl ) retryOptions () config.Retry { return co .ro }
135
+ func (co * consenterImpl ) tlsConfig () config.TLS { return co .tls }
133
136
func (co * consenterImpl ) brokFunc () bfType { return co .bf }
134
137
func (co * consenterImpl ) prodFunc () pfType { return co .pf }
135
138
func (co * consenterImpl ) consFunc () cfType { return co .cf }
@@ -169,7 +172,7 @@ func (ch *chainImpl) Start() {
169
172
}
170
173
171
174
// 2. Set up the listener/consumer for this partition.
172
- consumer , err := ch .consenter .consFunc ()(ch .support .SharedConfig ().KafkaBrokers (), ch .consenter .kafkaVersion (), ch .partition , ch .lastOffsetPersisted + 1 )
175
+ consumer , err := ch .consenter .consFunc ()(ch .support .SharedConfig ().KafkaBrokers (), ch .consenter .kafkaVersion (), ch .consenter . tlsConfig (), ch . partition , ch .lastOffsetPersisted + 1 )
173
176
if err != nil {
174
177
logger .Criticalf ("Cannot retrieve required offset from Kafka cluster for chain %s: %s" , ch .partition , err )
175
178
close (ch .exitChan )
0 commit comments