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

Allowing for async checks in fastApi. Cleaning up old code. #114

Merged
merged 3 commits into from
Apr 24, 2024

Conversation

alexcottner
Copy link
Contributor

Fixes #106 by running checks with run_checks_async.
Removed some old code that is no longer needed.

@alexcottner alexcottner requested a review from grahamalama April 24, 2024 19:12
@alexcottner alexcottner marked this pull request as ready for review April 24, 2024 19:12
grahamalama
grahamalama previously approved these changes Apr 24, 2024
Copy link
Contributor

@grahamalama grahamalama left a comment

Choose a reason for hiding this comment

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

Is there a test or tests we can write for this PR that assert that we can run all sync, mixed, and all async checks in a FastAPI heartbeat?

@@ -11,12 +11,12 @@ def lbheartbeat():
return {"status": "ok"}


def heartbeat(request: Request, response: Response):
async def heartbeat(request: Request, response: Response):
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if it's important to give users the choice to run these pre-baked views (and in this case, the underlying checks) synchronously or asynchronously, or if we should go all in on async at some point and make all of these FastAPI views async 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can't think of any real harm with allowing both sync/async checks to be ran. In general, I think async always makes more sense in an API context. But if some checks are simple things like "Do I have proper context/config?", then yeah that won't really be async.

@alexcottner alexcottner requested a review from grahamalama April 24, 2024 19:48
@alexcottner alexcottner merged commit 391f9ba into main Apr 24, 2024
58 checks passed
@alexcottner alexcottner deleted the fastapi-async-checks branch April 24, 2024 20:07
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.

Use run_checks_async with Fastapi (or allow customization through configuration)
2 participants