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

Maintain overall max request timeout (Optional) #5

Closed
karthikmuralidharan opened this issue Oct 4, 2017 · 9 comments
Closed

Maintain overall max request timeout (Optional) #5

karthikmuralidharan opened this issue Oct 4, 2017 · 9 comments

Comments

@karthikmuralidharan
Copy link
Contributor

Health Checks are called frequently, hence latency should ideally be low. Since most checks are to dependencies over the network, we need to make sure to timeout if the calls are not served within time.

While it's the responsibility of each checker func to maintain it's own TTL, having a max timeout value for a health check request might be a good idea.

This could be an optional feature.

@samnegri
Copy link

samnegri commented Oct 4, 2017

Hi, I'd like to work on this issue 😄

@karthikmuralidharan
Copy link
Contributor Author

@samnegri Sure, go ahead.

@karthikmuralidharan
Copy link
Contributor Author

@samnegri Might be good to use context with deadline. Thoughts ?

https://golang.org/pkg/context/#WithDeadline

@samnegri
Copy link

samnegri commented Oct 4, 2017

Seems good! I'll check it out after I leave work

@pcasaretto
Copy link
Contributor

Would it make sense for checkers to accept a context.Context ?

@karthikmuralidharan
Copy link
Contributor Author

karthikmuralidharan commented Oct 8, 2017

@pcasaretto I think so and I had the same thought as you did, but context is passed into checkers are mostly for request cancellation on the source (like cancelling the database query, close the tcp connection etc..).

Since checker funcs shouldn't be IO intensive in any way, I thought of leaving it out for sake of not breaking the interface. I'm open to suggestions though.

@pcasaretto
Copy link
Contributor

I see no other way of signaling cancellation. I'd suggest we break the interface while you haven't publicly version 1.
In terms of implementation, what should happen with checks that timeout?

@karthikmuralidharan
Copy link
Contributor Author

@pcasaretto Apologies for the delayed response.

I see no other way of signaling cancellation. I'd suggest we break the interface while you haven't publicly version 1.

Yes. I agree. If you'd like to send a cancellation signal to the underlying checker implementation in order to clear up the resources, then I can't think of a cleaner approach than sending in the context object.

If the goal is to simply return/ignore the results of the checker once the timeout has occurred, that can be done without the need for context. But that means resources will be locked up indefinitely unless the checker implementation has it's own timeout.

Since this project's pretty new, I think we can break the interface in favour of the cleaner approach.

In terms of implementation, what should happen with checks that timeout?
In case the timeout is exceeded, and let's say the database check was still pending, we'd have to signal the cancellation and return to handling the error responses.

Because certain implementations (custom like database) may choose not to handle context, I'm thinking we can't wait for the functions to return I suppose (Need to play around with the behaviour of context a little more personally :) ).

We append to the errors map of the pending checkers saying max check time exceeded.

What do you think ?

@pcasaretto
Copy link
Contributor

Sounds good to me!
Expect a PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants