-
Notifications
You must be signed in to change notification settings - Fork 1
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
refactor: add AndFilter and break down existing filters #64
Conversation
for i := range h.configs { | ||
config := h.configs[i] | ||
zap.L().Debug("Running healthchecks on upstream.", zap.String("upstreamID", config.ID)) | ||
for range h.healthCheckTicker.C { |
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.
Like the ticker!
internal/route/node_filter.go
Outdated
return result | ||
} | ||
|
||
type IsHealthyFilter struct { |
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.
nit: do we need Filter
in the name? The other structs don't have it.
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.
Or maybe just HealthyFilter
? I feel like this Is
prefix might be a little verbose. Indeed it's the general naming convention for boolean
methods but I feel like the intent is already communicated clearly without the Is
prefix.
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.
Went with IsHealthy
for consistency with the others.
aadd18b
to
704f56f
Compare
704f56f
to
cef5348
Compare
Description
This PR introduces an
AndFilter
that combines multipleNodeFilter
s and only passes if all sub-filters pass. This makes it very easy to add new filters and mix-and-match existing filters. The specific reason I'm adding this is to that I can add height-based or request-based filters in a follow-up PR and combine those with the existing ones.Some high-level notes:
HealthCheckManager
to use atime.Ticker
for testability. I wanted to confirm that theRunCheck
calls are executed as expected without waiting 5 seconds in the test, so I switched thetime.Sleep
call with an injected Ticker. That way, in the test, I can forceRunCheck
invocations by emitting an item on the Ticker channel.NodeFilterType
enum and add afilters:
section in the YAML config so people can choose which filters to use.node_filter.go
is getting a bit long. The individual types and functions are pretty short still so it seems tolerable. We can break it up into multiple files or a package when it gets unwieldy.Type of change
How Has This Been Tested?
Unit tests for
AndFilter
and updated test for theHealthCheckManager
.