Skip to content
Discussion options

You must be logged in to vote

Hi, faststream has a dependency injection mechanism via Context, you can read about it here. Also here is the documentation on how to set up Context in lifespan.

I've slightly corrected your code for better clarity:

  1. Fixed example
import logging
import os
from contextlib import asynccontextmanager
from typing import Annotated

from faststream import FastStream, Context, ContextRepo
from faststream.rabbit import RabbitBroker

COS_DATA_DIR = os.getenv("TARGET_COS_DATASET_DIR") or "/dataset"
FILE_ENDPOINT = os.getenv("FILE_ENDPOINT")
TOKEN_ENDPOINT = os.getenv("TOKEN_ENDPOINT")


class AsyncFileClient:
    def __init__(self, *args, **kwargs) -> None:
        ...

    async def upload_file(self

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Lancetnik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants