Skip to content
Snippets Groups Projects
Commit 91830f5a authored by CodingSinger's avatar CodingSinger
Browse files

add some comments

parent 96745731
No related branches found
No related tags found
No related merge requests found
......@@ -37,11 +37,11 @@ func init() {
// DefaultHealthChecker is the default implementation of HealthChecker, which determines the health status of
// the invoker based on the number of successive bad request and the current active request.
type DefaultHealthChecker struct {
// outStandingRequestConutLimit
// the limit of outstanding request
outStandingRequestConutLimit int32
// requestSuccessiveFailureThreshold
// the threshold of successive-failure-request
requestSuccessiveFailureThreshold int32
// requestSuccessiveFailureThreshold
// value of circuit-tripped timeout factor
circuitTrippedTimeoutFactor int32
}
......
......@@ -39,9 +39,10 @@ type HealthCheckRouter struct {
// NewHealthCheckRouter construct an HealthCheckRouter via url
func NewHealthCheckRouter(url *common.URL) (router.Router, error) {
r := &HealthCheckRouter{}
r.url = url
r.enabled = url.GetParamBool(HEALTH_ROUTE_ENABLED_KEY, false)
r := &HealthCheckRouter{
url: url,
enabled: url.GetParamBool(HEALTH_ROUTE_ENABLED_KEY, false),
}
if r.enabled {
checkerName := url.GetParam(constant.HEALTH_CHECKER, constant.DEFAULT_HEALTH_CHECKER)
r.checker = extension.GetHealthChecker(checkerName, url)
......@@ -54,7 +55,7 @@ func (r *HealthCheckRouter) Route(invokers []protocol.Invoker, url *common.URL,
if !r.enabled {
return invokers
}
var healthyInvokers []protocol.Invoker
healthyInvokers := make([]protocol.Invoker, 0, len(invokers))
// Add healthy invoker to the list
for _, invoker := range invokers {
if r.checker.IsHealthy(invoker) {
......@@ -65,9 +66,8 @@ func (r *HealthCheckRouter) Route(invokers []protocol.Invoker, url *common.URL,
if len(healthyInvokers) == 0 {
logger.Warnf(" Now all invokers are unhealthy, so downgraded to all! Service: [%s]", url.ServiceKey())
return invokers
} else {
return healthyInvokers
}
return healthyInvokers
}
// Priority
......
......@@ -193,13 +193,22 @@ const (
// HealthCheck Router
const (
HEALTH_CHECKER = "health.checker"
DEFAULT_HEALTH_CHECKER = "default"
OUTSTANDING_REQUEST_COUNT_LIMIT_KEY = "outstanding.request.limit"
SUCCESSIVE_FAILED_REQUEST_THRESHOLD_KEY = "successive.failed.threshold"
DEFAULT_SUCCESSIVE_FAILED_THRESHOLD = 5
CIRCUIT_TRIPPED_TIMEOUT_FACTOR_KEY = "circuit.tripped.timeout.factor"
// The key of HealthCheck SPI
HEALTH_CHECKER = "health.checker"
// The name of the default implementation of HealthChecker
DEFAULT_HEALTH_CHECKER = "default"
// The key of oustanding-request-limit
OUTSTANDING_REQUEST_COUNT_LIMIT_KEY = "outstanding.request.limit"
// The key of successive-failed-request's threshold
SUCCESSIVE_FAILED_REQUEST_THRESHOLD_KEY = "successive.failed.threshold"
// The key of circuit-tripped timeout factor
CIRCUIT_TRIPPED_TIMEOUT_FACTOR_KEY = "circuit.tripped.timeout.factor"
// The default threshold of successive-failed-request if not specfied
DEFAULT_SUCCESSIVE_FAILED_THRESHOLD = 5
// The default maximum diff between successive-failed-request's threshold and actual successive-failed-request's count
DEFAULT_SUCCESSIVE_FAILED_REQUEST_MAX_DIFF = 5
DEFAULT_CIRCUIT_TRIPPED_TIMEOUT_FACTOR = 1000
MAX_CIRCUIT_TRIPPED_TIMEOUT_IN_MS = 30000
// The default factor of circuit-tripped timeout if not specfied
DEFAULT_CIRCUIT_TRIPPED_TIMEOUT_FACTOR = 1000
// The default time window of circuit-tripped in millisecond if not specfied
MAX_CIRCUIT_TRIPPED_TIMEOUT_IN_MS = 30000
)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment