NewSyncProducer creates a new SyncProducer using the given broker addresses and configuration.
(addrs []string, config *Config)
| 75 | |
| 76 | // NewSyncProducer creates a new SyncProducer using the given broker addresses and configuration. |
| 77 | func NewSyncProducer(addrs []string, config *Config) (SyncProducer, error) { |
| 78 | if config == nil { |
| 79 | config = NewConfig() |
| 80 | config.Producer.Return.Successes = true |
| 81 | } |
| 82 | |
| 83 | if err := verifyProducerConfig(config); err != nil { |
| 84 | return nil, err |
| 85 | } |
| 86 | |
| 87 | p, err := NewAsyncProducer(addrs, config) |
| 88 | if err != nil { |
| 89 | return nil, err |
| 90 | } |
| 91 | return newSyncProducerFromAsyncProducer(p.(*asyncProducer)), nil |
| 92 | } |
| 93 | |
| 94 | // NewSyncProducerFromClient creates a new SyncProducer using the given client. It is still |
| 95 | // necessary to call Close() on the underlying client when shutting down this producer. |