diff options
author | John Cai <jcai@gitlab.com> | 2020-05-31 09:15:10 +0300 |
---|---|---|
committer | John Cai <jcai@gitlab.com> | 2020-06-22 19:53:14 +0300 |
commit | bf62340c329cf0c8e1595f9fa620af38ee4b1f3b (patch) | |
tree | a9237309832e84707cafdf10854f21464645c888 /internal/praefect/config | |
parent | 543d00cffaaf69b66c18e1f992b60d8f3671ed7f (diff) |
Adding error handler middleware to keep track of read/write errors
Diffstat (limited to 'internal/praefect/config')
-rw-r--r-- | internal/praefect/config/config.go | 9 | ||||
-rw-r--r-- | internal/praefect/config/config_test.go | 9 | ||||
-rw-r--r-- | internal/praefect/config/testdata/config.toml | 5 |
3 files changed, 17 insertions, 6 deletions
diff --git a/internal/praefect/config/config.go b/internal/praefect/config/config.go index e25f909ff..dc9024d05 100644 --- a/internal/praefect/config/config.go +++ b/internal/praefect/config/config.go @@ -15,9 +15,12 @@ import ( ) type Failover struct { - Enabled bool `toml:"enabled"` - ElectionStrategy string `toml:"election_strategy"` - ReadOnlyAfterFailover bool `toml:"read_only_after_failover"` + Enabled bool `toml:"enabled"` + ElectionStrategy string `toml:"election_strategy"` + ReadOnlyAfterFailover bool `toml:"read_only_after_failover"` + ErrorThresholdWindow config.Duration `toml:"error_threshold_window"` + WriteErrorThresholdCount uint32 `toml:"write_error_threshold_count"` + ReadErrorThresholdCount uint32 `toml:"read_error_threshold_count"` } const sqlFailoverValue = "sql" diff --git a/internal/praefect/config/config_test.go b/internal/praefect/config/config_test.go index 982565229..1944727f0 100644 --- a/internal/praefect/config/config_test.go +++ b/internal/praefect/config/config_test.go @@ -266,9 +266,12 @@ func TestConfigParsing(t *testing.T) { MemoryQueueEnabled: true, GracefulStopTimeout: config.Duration(30 * time.Second), Failover: Failover{ - Enabled: true, - ElectionStrategy: sqlFailoverValue, - ReadOnlyAfterFailover: true, + Enabled: true, + ElectionStrategy: sqlFailoverValue, + ReadOnlyAfterFailover: true, + ErrorThresholdWindow: config.Duration(20 * time.Second), + WriteErrorThresholdCount: 1500, + ReadErrorThresholdCount: 100, }, }, }, diff --git a/internal/praefect/config/testdata/config.toml b/internal/praefect/config/testdata/config.toml index 0628d9034..32b4c94db 100644 --- a/internal/praefect/config/testdata/config.toml +++ b/internal/praefect/config/testdata/config.toml @@ -41,3 +41,8 @@ sslmode = "require" sslcert = "/path/to/cert" sslkey = "/path/to/key" sslrootcert = "/path/to/root-cert" + +[failover] +error_threshold_window = "20s" +write_error_threshold_count = 1500 +read_error_threshold_count = 100 |