-
Notifications
You must be signed in to change notification settings - Fork 12
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
Rewrite search API to use fastapi, aioredis-py #3
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, coming from your blog post about FastAPI 👋
The FastAPI refactor looks pretty good to me. I agree that FastAPI's way of authentication leaves a bit to be desired.
docs = transform_documents(docs, search_site, q.query_string()) | ||
resp.body = json.dumps({"total": total, "results": docs}) | ||
from_url = from_url if from_url else '' | ||
start = start if isinstance(start, int) else 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is isinstance
necessary here, since start
has a type hint of Optional[int]
? FastAPI uses Pydantic under the hood, which will attempt to coerce anything passed-in to the function to an int
.
pydantic uses int(v) to coerce types to an int; see this warning on loss of information during data conversion
Rewrite the search API to use fastapi and aioredis-py.
Current benchmarks:
FastAPI
Falcon