Faststream

Latest version: v0.5.3

Safety actively analyzes 623360 Python packages for vulnerabilities to keep your Python projects secure.

Scan your dependencies

Page 1 of 9

0.5.3

What's Changed
* Update Release Notes for 0.5.2 by faststream-release-notes-updater in https://github.com/airtai/faststream/pull/1382
* Fix/setup at broker connection instead of starting by Lancetnik in https://github.com/airtai/faststream/pull/1385
* Tests/add path tests by Lancetnik in https://github.com/airtai/faststream/pull/1388
* Fix/path with router prefix by Lancetnik in https://github.com/airtai/faststream/pull/1395
* chore: update dependencies by Lancetnik in https://github.com/airtai/faststream/pull/1396
* chore: bump version by Lancetnik in https://github.com/airtai/faststream/pull/1397
* chore: polishing by davorrunje in https://github.com/airtai/faststream/pull/1399


**Full Changelog**: https://github.com/airtai/faststream/compare/0.5.2...0.5.3

0.5.2

What's Changed

Just a little bugfix patch. Fixes 1379 and 1376.

* Update Release Notes for 0.5.1 by faststream-release-notes-updater in https://github.com/airtai/faststream/pull/1378
* Tests/fastapi background by Lancetnik in https://github.com/airtai/faststream/pull/1380
* Fix/0.5.2 by Lancetnik in https://github.com/airtai/faststream/pull/1381


**Full Changelog**: https://github.com/airtai/faststream/compare/0.5.1...0.5.2

0.5.1

What's Changed

We already have some fixes related to `RedisBroker` (1375, 1376) and some new features for you:

1. Now `broke.include_router(...)` allows to pass some arguments to setup router at including moment instead of creation

python
broker.include_router(
router,
prefix="test_",
dependencies=[Depends(...)],
middlewares=[BrokerMiddleware],
include_in_schema=False,
)


2. `KafkaBroker().subscriber(...)` now consumes `aiokafka.ConsumerRebalanceListener` object.
You can find more information about it in the official [**aiokafka** doc](https://aiokafka.readthedocs.io/en/stable/consumer.html?highlight=subscribe#topic-subscription-by-pattern)

(close 1319)

python
broker = KafkaBroker()

broker.subscriber(..., listener=MyRebalancer())


`pattern` option was added too, but it is still experimental and does not support `Path`

3. [`Path`](https://faststream.airt.ai/latest/nats/message/#subject-pattern-access) feature perfomance was increased. Also, `Path` is suitable for NATS `PullSub` batch subscribtion as well now.

python
from faststream import NatsBroker, PullSub

broker = NastBroker()

broker.subscriber(
"logs.{level}",
steam="test-stream",
pull_sub=PullSub(batch=True),
)
async def base_handler(
...,
level: str = Path(),
):
...


* Update Release Notes for 0.5.0 by faststream-release-notes-updater in https://github.com/airtai/faststream/pull/1366
* chore: bump version by Lancetnik in https://github.com/airtai/faststream/pull/1372
* feat: kafka listener, extended include_router by Lancetnik in https://github.com/airtai/faststream/pull/1374
* Fix/1375 by Lancetnik in https://github.com/airtai/faststream/pull/1377


**Full Changelog**: https://github.com/airtai/faststream/compare/0.5.0...0.5.1

0.5.0

What's Changed

This is the biggest change since the creation of FastStream. We have completely refactored the entire package, changing the object registration mechanism, message processing pipeline, and application lifecycle. However, you won't even notice it—we've preserved all public APIs from breaking changes. The only feature not compatible with the previous code is the new middleware.

New features:

1. `await FastStream.stop()` method and `StopApplication` exception to stop a `FastStream` worker are added.

2. `broker.subscriber()` and `router.subscriber()` functions now return a `Subscriber` object you can use later.

python
subscriber = broker.subscriber("test")

subscriber(filter = lambda msg: msg.content_type == "application/json")
async def handler(msg: dict[str, Any]):
...

subscriber()
async def handler(msg: dict[str, Any]):
...


This is the preferred syntax for [filtering](https://faststream.airt.ai/latest/getting-started/subscription/filtering/) now (the old one will be removed in `0.6.0`)

3. The `router.publisher()` function now returns the correct `Publisher` object you can use later (after broker startup).

python
publisher = router.publisher("test")

router.subscriber("in")
async def handler():
await publisher.publish("msg")


(Until `0.5.0` you could use it in this way with `broker.publisher` only)

4. A list of `middlewares` can be passed to a `broker.publisher` as well:

python
broker = Broker(..., middlewares=())

broker.subscriber(..., middlewares=())
broker.publisher(..., middlewares=()) new feature
async def handler():
...


5. Broker-level middlewares now affect all ways to publish a message, so you can encode application outgoing messages here.

6. ⚠️ BREAKING CHANGE ⚠️ : both `subscriber` and `publisher` middlewares should be async context manager type

python
async def subscriber_middleware(call_next, msg):
return await call_next(msg)

async def publisher_middleware(call_next, msg, **kwargs):
return await call_next(msg, **kwargs)

broker.subscriber(
"in",
middlewares=(subscriber_middleware,),
)
broker.publisher(
"out",
middlewares=(publisher_middleware,),
)
async def handler(msg):
return msg


Such changes allow you two previously unavailable features:
* suppress any exceptions and pass fall-back message body to publishers, and
* patch any outgoing message headers and other parameters.

Without those features we could not implement [Observability Middleware](https://github.com/airtai/faststream/issues/916) or any similar tool, so it is the job that just had to be done.
7. A better **FastAPI** compatibility: `fastapi.BackgroundTasks` and `response_class` subscriber option are supported.

8. All `.pyi` files are removed, and explicit docstrings and methods options are added.

9. New subscribers can be registered in runtime (with an already-started broker):

python
subscriber = broker.subscriber("dynamic")
subscriber(handler_method)
...
broker.setup_subscriber(subscriber)
await subscriber.start()
...
await subscriber.close()


10. `faststream[docs]` distribution is removed.

* Update Release Notes for 0.4.7 by faststream-release-notes-updater in https://github.com/airtai/faststream/pull/1295
* 1129 - Create a publish command for the CLI by MRLab12 in https://github.com/airtai/faststream/pull/1151
* Chore: packages upgraded by davorrunje in https://github.com/airtai/faststream/pull/1306
* docs: fix typos by omahs in https://github.com/airtai/faststream/pull/1309
* chore: update dependencies by Lancetnik in https://github.com/airtai/faststream/pull/1323
* docs: fix misc by Lancetnik in https://github.com/airtai/faststream/pull/1324
* docs (1327): correct RMQ exhcanges behavior by Lancetnik in https://github.com/airtai/faststream/pull/1328
* fix: typer 0.12 exclude by Lancetnik in https://github.com/airtai/faststream/pull/1341
* 0.5.0 by Lancetnik in https://github.com/airtai/faststream/pull/1326
* close 1103
* close 840
* fix 690
* fix 1206
* fix 1227
* close 568
* close 1303
* close 1287
* feat 607
* Generate docs and linter fixes by davorrunje in https://github.com/airtai/faststream/pull/1348
* Fix types by davorrunje in https://github.com/airtai/faststream/pull/1349
* chore: update dependencies by Lancetnik in https://github.com/airtai/faststream/pull/1358
* feat: final middlewares by Lancetnik in https://github.com/airtai/faststream/pull/1357
* Docs/0.5.0 features by Lancetnik in https://github.com/airtai/faststream/pull/1360

New Contributors
* MRLab12 made their first contribution in https://github.com/airtai/faststream/pull/1151
* omahs made their first contribution in https://github.com/airtai/faststream/pull/1309

**Full Changelog**: https://github.com/airtai/faststream/compare/0.4.7...0.5.0

0.5.0rc2

What's Changed

This is the final API change before stable `0.5.0` release

⚠️ HAS BREAKING CHANGE

In it, we stabilize the behavior of publishers & subscribers middlewares

python
async def subscriber_middleware(call_next, msg):
return await call_next(msg)

async def publisher_middleware(call_next, msg, **kwargs):
return await call_next(msg, **kwargs)

broker.subscriber(
"in",
middlewares=(subscriber_middleware,),
)
broker.publisher(
"out",
middlewares=(publisher_middleware,),
)
async def handler(msg):
return msg


Such changes allows you two features previously unavailable

* suppress any exceptions and pas fall-back message body to publishers
* patch any outgoing message headers and other parameters

Without these features we just can't impelement [Observability Middleware](https://github.com/airtai/faststream/issues/916) or any similar tool, so it is the job to be done.

Now you are free to get access at any message processing stage and we are one step closer to the framework we would like to create!

* Update Release Notes for 0.5.0rc0 by faststream-release-notes-updater in https://github.com/airtai/faststream/pull/1347
* Generate docs and linter fixes by davorrunje in https://github.com/airtai/faststream/pull/1348
* Fix types by davorrunje in https://github.com/airtai/faststream/pull/1349
* chore: update dependencies by Lancetnik in https://github.com/airtai/faststream/pull/1358
* feat: final middlewares by Lancetnik in https://github.com/airtai/faststream/pull/1357


**Full Changelog**: https://github.com/airtai/faststream/compare/0.5.0rc0...0.5.0rc2

0.5.0rc0

We look forward to your feedback!

New features:

1. `await FastStream.stop()` method and `StopApplication` exception to stop a `FastStream` worker are added.

2. `broker.subscriber()` and `router.subscriber()` functions now return a `Subscriber` object you can use later.

python
subscriber = broker.subscriber("test")

subscriber(filter = lambda msg: msg.content_type == "application/json")
async def handler(msg: dict[str, Any]):
...

subscriber()
async def handler(msg: dict[str, Any]):
...


This is the preferred syntax for [filtering](https://faststream.airt.ai/latest/getting-started/subscription/filtering/) now (the old one will be removed in `0.6.0`)

3. The `router.publisher()` function now returns the correct `Publisher` object you can use later (after broker startup).

python
publisher = router.publisher("test")

router.subscriber("in")
async def handler():
await publisher.publish("msg")


(Until `0.5.0` you could use it in this way with `broker.publisher` only)

4. A list of `middlewares` can be passed to a `broker.publisher` as well:

python
broker = Broker(..., middlewares=())

broker.subscriber(..., middlewares=())
broker.publisher(..., middlewares=()) new feature
async def handler():
...


5. Broker-level middlewares now affect all ways to publish a message, so you can encode application outgoing messages here.

6. ⚠️ BREAKING CHANGE ⚠️ : both `subscriber` and `publisher` middlewares should be async context manager type

python
from contextlib import asynccontextmanager

asynccontextmanager
async def subscriber_middleware(msg_body):
yield msg_body

asynccontextmanager
async def publisher_middleware(
msg_to_publish,
**publish_arguments,
):
yield msg_to_publish

broker.subscriber("in", middlewares=(subscriber_middleware,))
broker.publisher("out", middlewares=(publisher_middleware,))
async def handler():
...


7. A better **FastAPI** compatibility: `fastapi.BackgroundTasks` and `response_class` subscriber option are supported.

8. All `.pyi` files are removed, and explicit docstrings and methods options are added.

9. New subscribers can be registered in runtime (with an already-started broker):

python
subscriber = broker.subscriber("dynamic")
subscriber(handler_method)
...
broker.setup_subscriber(subscriber)
await subscriber.start()
...
await subscriber.close()


10. `faststream[docs]` distribution is removed.

* Update Release Notes for 0.4.7 by faststream-release-notes-updater in https://github.com/airtai/faststream/pull/1295
* 1129 - Create a publish command for the CLI by MRLab12 in https://github.com/airtai/faststream/pull/1151
* Chore: packages upgraded by davorrunje in https://github.com/airtai/faststream/pull/1306
* docs: fix typos by omahs in https://github.com/airtai/faststream/pull/1309
* chore: update dependencies by Lancetnik in https://github.com/airtai/faststream/pull/1323
* docs: fix misc by Lancetnik in https://github.com/airtai/faststream/pull/1324
* docs (1327): correct RMQ exhcanges behavior by Lancetnik in https://github.com/airtai/faststream/pull/1328
* fix: typer 0.12 exclude by Lancetnik in https://github.com/airtai/faststream/pull/1341
* 0.5.0 by Lancetnik in https://github.com/airtai/faststream/pull/1326
* close 1103
* close 840
* fix 690
* fix 1206
* fix 1227
* close 568
* close 1303
* close 1287
* feat 607

New Contributors

* MRLab12 made their first contribution in https://github.com/airtai/faststream/pull/1151
* omahs made their first contribution in https://github.com/airtai/faststream/pull/1309

**Full Changelog**: https://github.com/airtai/faststream/compare/0.4.7...0.5.0rc0

Page 1 of 9

© 2024 Safety CLI Cybersecurity Inc. All Rights Reserved.