MCPcopy
hub / github.com/IBM/sarama / NewSyncProducer

Function NewSyncProducer

mocks/sync_producer.go:33–49  ·  view source on GitHub ↗

NewSyncProducer instantiates a new SyncProducer mock. The t argument should be the *testing.T instance of your test method. An error will be written to it if an expectation is violated. The config argument is validated and used to handle partitioning.

(t ErrorReporter, config *sarama.Config)

Source from the content-addressed store, hash-verified

31// an expectation is violated. The config argument is validated and used to handle
32// partitioning.
33func NewSyncProducer(t ErrorReporter, config *sarama.Config) *SyncProducer {
34 if config == nil {
35 config = sarama.NewConfig()
36 }
37 if err := config.Validate(); err != nil {
38 t.Errorf("Invalid mock configuration provided: %s", err.Error())
39 }
40 return &SyncProducer{
41 t: t,
42 expectations: make([]*producerExpectation, 0),
43 TopicConfig: NewTopicConfig(),
44 newPartitioner: config.Producer.Partitioner,
45 partitioners: make(map[string]sarama.Partitioner, 1),
46 isTransactional: config.Producer.Transaction.ID != "",
47 txnStatus: sarama.ProducerTxnFlagReady,
48 }
49}
50
51////////////////////////////////////////////////
52// Implement SyncProducer interface

Calls 5

NewConfigFunction · 0.92
NewTopicConfigFunction · 0.85
ValidateMethod · 0.80
ErrorfMethod · 0.65
ErrorMethod · 0.65