Releases: airtai/faststream
v0.4.4
What's Changed
Add RedisStream batch size option
@broker.subscriber(stream=StreamSub("input", batch=True, max_records=3))
async def on_input_data(msgs: list[str]):
assert len(msgs) <= 3
- Update Release Notes for 0.4.3 by @faststream-release-notes-updater in #1247
- docs: add manual run section by @Lancetnik in #1249
- feat (#1252): respect Redis StreamSub last_id with consumer group by @Lancetnik in #1256
- fix: correct Redis consumer group behavior by @Lancetnik in #1258
- feat: add Redis Stream max_records option by @Lancetnik in #1259
Full Changelog: 0.4.3...0.4.4
v0.4.3
What's Changed
Allow to specify Redis Stream maxlen option in publisher:
@broker.publisher(stream=StreamSub("Output", maxlen=10))
async def on_input_data():
....
- chore: bump version by @Lancetnik in #1198
- Update Release Notes for 0.4.2 by @faststream-release-notes-updater in #1199
- Add missing API documentation for apply_pattern by @kumaranvpl in #1201
- chore: polishing by @davorrunje in #1203
- Comment out retry and timeout in a confluent test by @kumaranvpl in #1207
- Commit offsets only if auto_commit is True by @kumaranvpl in #1208
- Add a CI job to check for missed docs changes by @kumaranvpl in #1217
- fix: inconsistent NATS publisher signature by @Lancetnik in #1218
- Upgrade packages by @davorrunje in #1226
- chore: bump dawidd6/action-download-artifact from 3.0.0 to 3.1.1 by @dependabot in #1239
- chore: bump dependencies by @Lancetnik in #1246
- feat (#1235): StreamSub maxlen parameter by @Lancetnik in #1245
- fix (#1234): correct FastAPI path passing, fix typehints by @Lancetnik in #1236
- fix (#1231): close RMQ while reconnecting by @Lancetnik in #1238
Full Changelog: 0.4.2...0.4.3
v0.4.2
What's Changed
Bug fixes
- fix: correct RMQ Topic testing routing by @Lancetnik in #1196
- fix #1191: correct RMQ ssl default port by @Lancetnik in #1195
- fix #1143: ignore Depends in AsyncAPI by @Lancetnik in #1197
Full Changelog: 0.4.1...0.4.2
v0.4.1
What's Changed
Bug fixes
- Fix: use FastAPI overrides in subscribers by @Lancetnik in #1189
- Handle confluent consumer commit failure by @kumaranvpl in #1193
Documentation
- Include Confluent in home and features pages by @kumaranvpl in #1186
- Use pydantic model for publishing in docs example by @kumaranvpl in #1187
Full Changelog: 0.4.0...0.4.1
v0.4.0
What's Changed
This release adds support for the Confluent's Python Client for Apache Kafka (TM). Confluent's Python Client for Apache Kafka does not support natively async
functions and its integration with modern async-based services is a bit trickier. That was the reason why our initial supported by Kafka broker used aiokafka. However, that choice was a less fortunate one as it is as well maintained as the Confluent version. After receiving numerous requests, we finally decided to bite the bullet and create an async
wrapper around Confluent's Python Client and add full support for it in FastStream.
If you want to try it out, install it first with:
pip install "faststream[confluent]>=0.4.0"
To connect to Kafka using the FastStream KafkaBroker module, follow these steps:
-
Initialize the KafkaBroker instance: Start by initializing a KafkaBroker instance with the necessary configuration, including Kafka broker address.
-
Create your processing logic: Write a function that will consume the incoming messages in the defined format and produce a response to the defined topic
-
Decorate your processing function: To connect your processing function to the desired Kafka topics you need to decorate it with
@broker.subscriber(...)
and@broker.publisher(...)
decorators. Now, after you start your application, your processing function will be called whenever a new message in the subscribed topic is available and produce the function return value to the topic defined in the publisher decorator.
Here's a simplified code example demonstrating how to establish a connection to Kafka using FastStream's KafkaBroker module:
from faststream import FastStream
from faststream.confluent import KafkaBroker
broker = KafkaBroker("localhost:9092")
app = FastStream(broker)
@broker.subscriber("in-topic")
@broker.publisher("out-topic")
async def handle_msg(user: str, user_id: int) -> str:
return f"User: {user_id} - {user} registered"
For more information, please visit the documentation at:
https://faststream.airt.ai/latest/confluent/
List of Changes
- Update Release Notes for 0.3.13 by @faststream-release-notes-updater in #1119
- docs: close #1125 by @Lancetnik in #1126
- Add support for confluent python lib by @kumaranvpl in #1042
- Update tutorial docs to include confluent code examples by @kumaranvpl in #1131
- Add installation instructions for confluent by @kumaranvpl in #1132
- Update Release Notes for 0.4.0rc0 by @faststream-release-notes-updater in #1130
- chore: remove useless branch from CI by @Lancetnik in #1135
- chore: bump mkdocs-git-revision-date-localized-plugin from 1.2.1 to 1.2.2 by @dependabot in #1140
- chore: strict fast-depends version by @Lancetnik in #1145
- chore: update copyright by @Lancetnik in #1144
- fix: correct Windows shutdown by @Lancetnik in #1148
- docs: fix typo by @saroz014 in #1154
- Middleware Document Syntax Error by @SepehrBazyar in #1156
- fix: correct FastAPI Context type hints by @Lancetnik in #1155
- Fix bug which results in lost confluent coverage report by @kumaranvpl in #1160
- Fix failing ack tests for confluent by @kumaranvpl in #1166
- Update version to 0.4.0 and update docs by @kumaranvpl in #1171
- feat #1180: add StreamRouter.on_broker_shutdown hook by @Lancetnik in #1182
- Fix bug - using old upload-artifact version by @kumaranvpl in #1183
- Release 0.4.0 by @davorrunje in #1184
New Contributors
Full Changelog: 0.3.13...0.4.0
v0.4.0rc0
What's Changed
This is a preview version of 0.4.0 release introducing support for Confluent-based Kafka broker.
Here's a simplified code example demonstrating how to establish a connection to Kafka using FastStream's KafkaBroker module:
from faststream import FastStream
from faststream.confluent import KafkaBroker
broker = KafkaBroker("localhost:9092")
app = FastStream(broker)
@broker.subscriber("in-topic")
@broker.publisher("out-topic")
async def handle_msg(user: str, user_id: int) -> str:
return f"User: {user_id} - {user} registered"
Changes
- Add support for confluent python lib by @kumaranvpl in #1042
Full Changelog: 0.3.13...0.4.0rc0
v0.3.13
What's Changed
New features
- New shutdown logic by @Lancetnik in #1117
Bug fixes
New Contributors
Full Changelog: 0.3.12...0.3.13
v0.3.12
What's Changed
Bug fixes
- fix (#1110): correct RMQ Topic pattern test publish by @Lancetnik in #1112
Misc
- chore: upgraded packages, black replaced with ruff format by @davorrunje in #1097
- chore: upgraded packages by @davorrunje in #1111
Full Changelog: 0.3.11...0.3.12
v0.3.11
What's Changed
NATS concurent subscriber:
By default, NATS subscriber consumes messages with a block per subject. So, you can't process multiple messages from the same subject at the same time. But, with the broker.subscriber(..., max_workers=...)
option, you can! It creates an async tasks pool to consume multiple messages from the same subject and allows you to process them concurrently!
from faststream import FastStream
from faststream.nats import NatsBroker
broker = NatsBroker()
app = FastStream()
@broker.subscriber("test-subject", max_workers=10)
async def handler(...):
"""Can process up to 10 messages concurrently."""
- Update Release Notes for 0.3.10 by @faststream-release-notes-updater in #1091
- fix (#1100): FastAPI 0.106 compatibility by @Lancetnik in #1102
Full Changelog: 0.3.10...0.3.11
v0.3.10
What's Changed
New features
- feat: Context initial option by @Lancetnik in #1086
Bug fixes
- fix (#1087): add app_dir option to docs serve/gen commands by @Lancetnik in #1088
Documentation
- docs: add Context initial section by @Lancetnik in #1089
Other
- chore: linting by @davorrunje in #1081
- chore: delete accidentally added .bak file by @kumaranvpl in #1085
Full Changelog: 0.3.9...0.3.10