Skip to content

fix readiness check function#72

Merged
bnusunny merged 1 commit intomainfrom
fix_readiness_check
Sep 9, 2022
Merged

fix readiness check function#72
bnusunny merged 1 commit intomainfrom
fix_readiness_check

Conversation

@bnusunny
Copy link
Copy Markdown
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
Comment thread src/lib.rs
@@ -95,20 +95,13 @@ impl Adapter {

async fn check_readiness(&self) -> bool {
Copy link
Copy Markdown
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.

Comment thread src/lib.rs
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
Copy Markdown
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
Copy Markdown
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