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

two step circuit breaker #6

Merged
merged 7 commits into from
May 30, 2017
Merged

two step circuit breaker #6

merged 7 commits into from
May 30, 2017

Conversation

aryszka
Copy link
Contributor

@aryszka aryszka commented May 24, 2017

providing a two-step circuit breaker where checking whether a request can proceed and reporting the otucome is separated.

see previous discussions on the topic in #4

@coveralls
Copy link

Coverage Status

Coverage decreased (-13.9%) to 84.906% when pulling a77fa11 on aryszka:master into 809bcd5 on sony:master.

gobreaker.go Outdated
@@ -146,6 +153,13 @@ func NewCircuitBreaker(st Settings) *CircuitBreaker {
return cb
}

// NewTwoStep returns a new TwoStepCircuitBreaker configured with the given Settings.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to rename NewTwoStep to NewTwoStepCircuitBreaker .

@@ -52,11 +62,46 @@ func fail(cb *CircuitBreaker) error {
return err
}

func fail2Step(cb *TwoStepCircuitBreaker) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think fail2Step should return error.

@@ -211,6 +239,61 @@ func TestCustomCircuitBreaker(t *testing.T) {
assert.Equal(t, StateChange{"cb", StateHalfOpen, StateClosed}, stateChange)
}

func TestMultiStepBreaker(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to rename TestMultiStepBreaker to TestTwoStepCircuitBreaker.

@@ -211,6 +239,61 @@ func TestCustomCircuitBreaker(t *testing.T) {
assert.Equal(t, StateChange{"cb", StateHalfOpen, StateClosed}, stateChange)
}

func TestMultiStepBreaker(t *testing.T) {
cb := &TwoStepCircuitBreaker{cb: defaultCB}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use NewTwoStepCircuitBreaker, which improves code coverage.

- renamed twostep breaker constructor
- fixed failure test call to return an error
@coveralls
Copy link

Coverage Status

Coverage decreased (-11.4%) to 87.442% when pulling 0bb8346 on aryszka:master into 809bcd5 on sony:master.

@YoshiyukiMineo YoshiyukiMineo merged commit e9556a4 into sony:master May 30, 2017
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.

4 participants