MM-31063: Change constants to use CamelCase (#16608)

* MM-31063: Change constants to use CamelCase

* store package

* change allcaps to camel case (#16615)

* New tools.mod

Co-authored-by: Ibrahim Serdar Acikgoz <serdaracikgoz86@gmail.com>
Этот коммит содержится в:
Agniva De Sarker
2021-01-04 11:32:29 +05:30
коммит произвёл GitHub
родитель 8b6ac5f5d2
Коммит c1dd23a3c8
158 изменённых файлов: 1485 добавлений и 1479 удалений

Просмотреть файл

@@ -12,10 +12,10 @@ import (
)
const (
HEALTH_CHECK_INTERVAL = 30 * time.Second // How often the health check should run
HEALTH_CHECK_DEACTIVATION_WINDOW = 60 * time.Minute // How long we wait for num fails to occur before deactivating the plugin
HEALTH_CHECK_PING_FAIL_LIMIT = 3 // How many times we call RPC ping in a row before it is considered a failure
HEALTH_CHECK_NUM_RESTARTS_LIMIT = 3 // How many times we restart a plugin before we deactivate it
HealthCheckInterval = 30 * time.Second // How often the health check should run
HealthCheckDeactivationWindow = 60 * time.Minute // How long we wait for num fails to occur before deactivating the plugin
HealthCheckPingFailLimit = 3 // How many times we call RPC ping in a row before it is considered a failure
HealthCheckNumRestartsLimit = 3 // How many times we restart a plugin before we deactivate it
)
type PluginHealthCheckJob struct {
@@ -31,7 +31,7 @@ func (job *PluginHealthCheckJob) run() {
mlog.Debug("Plugin health check job starting.")
defer close(job.cancelled)
ticker := time.NewTicker(HEALTH_CHECK_INTERVAL)
ticker := time.NewTicker(HealthCheckInterval)
defer ticker.Stop()
for {
@@ -103,21 +103,21 @@ func (job *PluginHealthCheckJob) Cancel() {
<-job.cancelled
}
// shouldDeactivatePlugin determines if a plugin needs to be deactivated after the plugin has failed (HEALTH_CHECK_NUM_RESTARTS_LIMIT) times,
// within the configured time window (HEALTH_CHECK_DEACTIVATION_WINDOW).
// shouldDeactivatePlugin determines if a plugin needs to be deactivated after the plugin has failed (HealthCheckNumRestartsLimit) times,
// within the configured time window (HealthCheckDeactivationWindow).
func shouldDeactivatePlugin(failedTimestamps []time.Time) bool {
if len(failedTimestamps) < HEALTH_CHECK_NUM_RESTARTS_LIMIT {
if len(failedTimestamps) < HealthCheckNumRestartsLimit {
return false
}
index := len(failedTimestamps) - HEALTH_CHECK_NUM_RESTARTS_LIMIT
return time.Since(failedTimestamps[index]) <= HEALTH_CHECK_DEACTIVATION_WINDOW
index := len(failedTimestamps) - HealthCheckNumRestartsLimit
return time.Since(failedTimestamps[index]) <= HealthCheckDeactivationWindow
}
// removeStaleTimestamps only keeps the last HEALTH_CHECK_NUM_RESTARTS_LIMIT items in timestamps.
// removeStaleTimestamps only keeps the last HealthCheckNumRestartsLimit items in timestamps.
func removeStaleTimestamps(timestamps []time.Time) []time.Time {
if len(timestamps) > HEALTH_CHECK_NUM_RESTARTS_LIMIT {
timestamps = timestamps[len(timestamps)-HEALTH_CHECK_NUM_RESTARTS_LIMIT:]
if len(timestamps) > HealthCheckNumRestartsLimit {
timestamps = timestamps[len(timestamps)-HealthCheckNumRestartsLimit:]
}
return timestamps