-
Notifications
You must be signed in to change notification settings - Fork 623
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
add conviction policy interface #1081
Conversation
* test commit * stub * add reconnection policy * add debug message * add conviction policy interface and tests * changes for a new branch * fix code comment and default setting * fix broken test * change default setting * remove conviction policy (now in #1081), add myself in AUTHORS * fix code comment * fix variable naming for ConstantReconnectionPolicy
policies.go
Outdated
|
||
type ConvictionPolicy interface { | ||
// Implementations should return `true` if the host should be convicted, `false` otherwise. | ||
AddFailure(error error) bool |
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.
Surely this should take the host info that caused the error?
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.
Some minor things re comments then I think this is good to go.
Something to note is that for Go comments for publicly exposed types/functions should be formatted like https://golang.org/doc/effective_go.html#commentary
policies.go
Outdated
// Implementations should return `true` if the host should be convicted, `false` otherwise. | ||
AddFailure(error error, host *HostInfo) bool | ||
//Implementations should clear out any convictions or state regarding the host. | ||
Reset() |
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.
Should this not also take a host given the comment?
policies.go
Outdated
Reset() | ||
} | ||
|
||
//return true on any error |
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.
Improve this comment, something like
SimpleConvictionPolicy implements a ConvictionPolicy which convicts all hosts regardless of error
policies.go
Outdated
@@ -791,6 +791,22 @@ func (d *dcAwareRR) Pick(q ExecutableQuery) NextHost { | |||
} | |||
} | |||
|
|||
type ConvictionPolicy interface { |
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.
Also add a comment explaining what this interface is for.
@Zariel thanks - fixed the comments and Reset function as suggested |
#1079
Conviction policy:
decide when to mark the host as 'down' based on the error. Default:
SimpleConvictionPolicy
- mark host as 'down' on any error.Opened interface in policies.go for user to implement their own policies.