Fix kafka input binding looping when not topics are set (#1412)

* binding kafka: check if topics are not empty before reading

Signed-off-by: Tim Burkert <burkert.tim@gmail.com>

* binding kafka: log warning instead of returning error

Signed-off-by: Tim Burkert <burkert.tim@gmail.com>

Co-authored-by: Yaron Schneider <schneider.yaron@live.com>
Co-authored-by: Artur Souza <artursouza.ms@outlook.com>
Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com>
This commit is contained in:
Gehhilfe 2022-01-07 20:06:17 +01:00 committed by GitHub
parent 4631d6e41a
commit 8332b6a9c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -226,6 +226,11 @@ func (k *Kafka) getSyncProducer(meta *kafkaMetadata) (sarama.SyncProducer, error
}
func (k *Kafka) Read(handler func(*bindings.ReadResponse) ([]byte, error)) error {
if len(k.topics) == 0 {
k.logger.Warnf("kafka binding: no topic defined, input bindings will not be started")
return nil
}
config := sarama.NewConfig()
config.Version = sarama.V1_0_0_0
config.Consumer.Offsets.Initial = k.initialOffset