airtai / faststream

FastStream is a powerful and easy-to-use Python framework for building asynchronous services interacting with event streams such as Apache Kafka, RabbitMQ, NATS and Redis.
https://faststream.airt.ai/latest/
Apache License 2.0
2.5k stars 128 forks source link

Add allow_auto_create_topics to make automatic topic creation configurable #1556

Closed kumaranvpl closed 3 months ago

kumaranvpl commented 3 months ago

Description

We used to always create topics automatically and provided no way to make it configurable. This PR introduces a new variable called allow_auto_create_topics to make automatic topic creation configurable. I have included a warning when allow_auto_create_topics is set to False because confluent-kafka-python backfires/crumbles terribly if it tries to access an non existent topic as mentioned here - https://github.com/confluentinc/confluent-kafka-python/issues/1547. There were few blocking calls in the __init__ method of Async Confluent Producer and Consumer. I have used run_in_executor to make them non-blocking.

Fixes #1486, #1363

Type of change

Please delete options that are not relevant.

Checklist