Skip to content

Add FastStream example to docs#958

Open
birthdaysgift wants to merge 3 commits intoets-labs:developfrom
birthdaysgift:master
Open

Add FastStream example to docs#958
birthdaysgift wants to merge 3 commits intoets-labs:developfrom
birthdaysgift:master

Conversation

@birthdaysgift
Copy link
Copy Markdown

@birthdaysgift birthdaysgift commented Apr 17, 2026

Despite FastStream uses FastDepends under the hood the existing example for FastDepends from documentation doesn't work out of the box when used in FastStream handlers.

So I thought that having an explicit example of how to use dependency_injector with FastStream would be helpful for other devs seeking for a solution for such integration.

Comment thread docs/examples/faststream.rst Outdated
Comment on lines +3 to +4
FastStream example
=============
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FastStream example
=============
FastStream example
==================

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +21 to +24
counter = providers.Singleton(Counter)


broker = RedisBroker("redis://redis", logger=None)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
counter = providers.Singleton(Counter)
broker = RedisBroker("redis://redis", logger=None)
config = providers.Configuration()
counter = providers.Singleton(Counter)
broker = providers.Resource(RedisBroker, config.redis_url, logger=None)
app = providers.Factory(FastStream, broker, logger=None)

If we're demonstrating integration, it would be better to go all-out.

Comment on lines +51 to +52

await FastStream(broker, logger=None).run()
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see comment above

Suggested change
await FastStream(broker, logger=None).run()
app = await container.app()
await app.run()



def main():
client = redis.Redis(host="redis", port=6379)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No DI container?

Copy link
Copy Markdown
Author

@birthdaysgift birthdaysgift Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, for the sake of simplicity)

since we already have fastapi-redis example do you think this example needs DI container for redis as well?

Comment thread examples/miniapps/faststream/README.rst Outdated
Comment thread examples/miniapps/faststream/docker-compose.yml Outdated
Comment thread docs/examples/faststream.rst
Comment thread examples/miniapps/faststream/run.sh Outdated
Comment thread examples/miniapps/faststream/run.sh
@ZipFile ZipFile changed the base branch from master to develop April 18, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants