Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

intial fastapi http transport #498

Closed
wants to merge 2 commits into from
Closed

intial fastapi http transport #498

wants to merge 2 commits into from

Conversation

aconchillo
Copy link
Contributor

No description provided.

@aconchillo aconchillo marked this pull request as draft September 24, 2024 06:44
@aconchillo aconchillo requested a review from kwindla September 24, 2024 06:44
@aconchillo
Copy link
Contributor Author

aconchillo commented Sep 24, 2024

@kwindla The idea is that the developer subclasses FastAPIHTTPTransport and implements:

    async def input_generator(self, request: Request) -> AsyncGenerator[str | bytes, None]:
        pass

which will load the request body and will yield all the data in it. This way we don't force the format of the HTTP request.

and

    async def handle_request(self, request: Request) -> Response:
        pass

here the developer needs to call self.input().handle_request(request) and then return a response.

    async def handle_request(self, request: Request) -> Response:
        await self.input().handle_request(request)
        return EventSourceResponse(self.output().output_generator())

By not implementing a default handle_request() we allow the developer to return whatever they want. Doesn't need to be SSE.

@aconchillo
Copy link
Contributor Author

aconchillo commented Sep 25, 2024

@kwindla I think I'm going to close this for now. I believe there are probably better ways to work with HTTP. For example, I will now create a AsyncGeneratorProcessor that will have a serializer and will yield serialized frames. We can then use this generator in SSE for example or however we want.

For the input case we can just push frames to the pipeline. And the frames we push can be built from whatever we send from HTTP.

@aconchillo
Copy link
Contributor Author

Closing. We can revisit if we really need an HTTP transport. The AsyncGeneratorProcessor I mentioned was added here #506

@aconchillo aconchillo closed this Sep 25, 2024
@aconchillo aconchillo deleted the aleix/khk/http branch October 23, 2024 20:50
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