Skip to content

Commit

Permalink
Merge pull request #746 from watermelo/Fix/rename_health_checher
Browse files Browse the repository at this point in the history
Fix: rename SethealthChecker to SetHealthChecker
  • Loading branch information
AlexStocks authored Sep 10, 2020
2 parents e7d38aa + c9726e4 commit 7bb924a
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions cluster/router/healthcheck/default_health_check.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

func init() {
extension.SethealthChecker(constant.DEFAULT_HEALTH_CHECKER, NewDefaultHealthChecker)
extension.SetHealthChecker(constant.DEFAULT_HEALTH_CHECKER, NewDefaultHealthChecker)
}

// DefaultHealthChecker is the default implementation of HealthChecker, which determines the health status of
Expand Down Expand Up @@ -85,7 +85,7 @@ func (c *DefaultHealthChecker) getCircuitBreakerSleepWindowTime(status *protocol
} else if diff > constant.DEFAULT_SUCCESSIVE_FAILED_REQUEST_MAX_DIFF {
diff = constant.DEFAULT_SUCCESSIVE_FAILED_REQUEST_MAX_DIFF
}
sleepWindow := (1 << diff) * c.GetCircuitTrippedTimeoutFactor()
sleepWindow := (1 << uint(diff)) * c.GetCircuitTrippedTimeoutFactor()
if sleepWindow > constant.MAX_CIRCUIT_TRIPPED_TIMEOUT_IN_MS {
sleepWindow = constant.MAX_CIRCUIT_TRIPPED_TIMEOUT_IN_MS
}
Expand Down
4 changes: 2 additions & 2 deletions common/extension/health_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ var (
healthCheckers = make(map[string]func(url *common.URL) router.HealthChecker)
)

// SethealthChecker sets the HealthChecker with @name
func SethealthChecker(name string, fcn func(_ *common.URL) router.HealthChecker) {
// SetHealthChecker sets the HealthChecker with @name
func SetHealthChecker(name string, fcn func(_ *common.URL) router.HealthChecker) {
healthCheckers[name] = fcn
}

Expand Down
4 changes: 2 additions & 2 deletions common/extension/health_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

func TestGetHealthChecker(t *testing.T) {
SethealthChecker("mock", newMockhealthCheck)
SetHealthChecker("mock", newMockHealthCheck)
checker := GetHealthChecker("mock", common.NewURLWithOptions())
assert.NotNil(t, checker)
}
Expand All @@ -44,6 +44,6 @@ func (m mockHealthChecker) IsHealthy(invoker protocol.Invoker) bool {
return true
}

func newMockhealthCheck(_ *common.URL) router.HealthChecker {
func newMockHealthCheck(_ *common.URL) router.HealthChecker {
return &mockHealthChecker{}
}

0 comments on commit 7bb924a

Please sign in to comment.