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

fix readiness check function #72

Merged
merged 1 commit into from
Sep 9, 2022
Merged

fix readiness check function #72

merged 1 commit into from
Sep 9, 2022

Conversation

bnusunny
Copy link
Contributor

@bnusunny bnusunny commented Sep 8, 2022

The new readiness check function error out on the first request to web server. The readiness check needs to retry the check repeatly.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@bnusunny bnusunny requested a review from calavera September 8, 2022 16:33
@@ -95,20 +95,13 @@ impl Adapter {

async fn check_readiness(&self) -> bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

this function doesn't need to be async if the request blocks the thread.

@@ -95,20 +95,13 @@ impl Adapter {

async fn check_readiness(&self) -> bool {
Retry::spawn(FixedInterval::from_millis(10), || {
let fut = self.check_health_url();
async move { fut.await }
match reqwest::blocking::get(&self.healthcheck_url) {
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason to use GET request and not HEAD? if the url you're checking is a homepage, the response could be really big. A HEAD request should work as well, without fetching the body.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

GET request allows the server to do additional actions, such as warm up cache and preload dependencies. HEAD request does not guarantee that. Servers might just return the headers and not do any extra actions.

I see the benefit of using HEAD request. We can make it an option for developers to choose. That should be another PR.

@bnusunny bnusunny merged commit 5ff58ae into main Sep 9, 2022
@calavera calavera deleted the fix_readiness_check branch September 9, 2022 00:49
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