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

integration of flatbuffers in request and response #9

Open
sandys opened this issue Sep 15, 2019 · 2 comments
Open

integration of flatbuffers in request and response #9

sandys opened this issue Sep 15, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects

Comments

@sandys
Copy link

sandys commented Sep 15, 2019

Flatbuffers is the high performance serialization library from Google - https://google.github.io/flatbuffers/flatbuffers_guide_use_python.html

It has compatible libraries for java (android), javascript and python.

Is it possible for you to create functionality that happens automatically for each endpoint - that it accepts data in flatbuffers and gives response in flatbuffers if the request has Accept: application/x-flatbuffers in it.

e.g. curl -D- -H "Accept: application/x-flatbuffers" http://localhost:7002

if the header is not present, then the endpoint works with default json

@levchik levchik self-assigned this Sep 16, 2019
@levchik levchik added enhancement New feature or request help wanted Extra attention is needed labels Sep 16, 2019
@levchik
Copy link
Contributor

levchik commented Sep 16, 2019

Hi @sandys,

I've been thinking about how we could add new serialization formats into this lib, specifically about Avro, protobuf & msgpack. Now there's another format that you propose, so I guess this might be implemented in the future. There is actually not much work to do: create custom Response class & Route class. Reference: tiangolo/fastapi#521

But it would require additional deps to be installed. I guess we can just copy-paste the somewhat standard practice of making optional deps and making them required only for specific features. For example, pip install fastapi_contrib[msgpack] or pip install fastapi_contrib[flatbuffers]. Thus we can also make ujson optional as I wanted since the start :)

I don't think I have time to do something like this in next couple of weeks, but you are very welcome to send PR.

@dmontagu
Copy link

My understanding is that protobuf and flatbuffer should be pretty similar to implement (I haven't looked into it deeply though). The biggest challenge seems to me to be generating the specs from the pydantic models -- that may be worth a pydantic feature request (if such a request hasn't already been addressed anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
Roadmap
  
Awaiting triage
Development

No branches or pull requests

3 participants