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

add conviction policy interface #1081

Merged
merged 7 commits into from
May 5, 2018
Merged

add conviction policy interface #1081

merged 7 commits into from
May 5, 2018

Conversation

changliuau
Copy link
Contributor

@changliuau changliuau commented Mar 20, 2018

#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.

Zariel pushed a commit that referenced this pull request Mar 20, 2018
* 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
Copy link
Contributor

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?

Copy link
Contributor

@Zariel Zariel left a 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()
Copy link
Contributor

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
Copy link
Contributor

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 {
Copy link
Contributor

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.

@changliuau
Copy link
Contributor Author

@Zariel thanks - fixed the comments and Reset function as suggested

@Zariel Zariel merged commit 3a24f01 into apache:master May 5, 2018
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