diff --git a/app.go b/app.go index ce51cef..bd9dd1d 100644 --- a/app.go +++ b/app.go @@ -114,6 +114,7 @@ func newApp(ctx context.Context, opt ...Option) App { prm.SetNodeDialTimeout(a.cfg.GetDuration(cfgConTimeout)) prm.SetHealthcheckTimeout(a.cfg.GetDuration(cfgReqTimeout)) prm.SetClientRebalanceInterval(a.cfg.GetDuration(cfgRebalance)) + prm.SetErrorThreshold(a.cfg.GetUint32(cfgPoolErrorThreshold)) for i := 0; ; i++ { address := a.cfg.GetString(cfgPeers + "." + strconv.Itoa(i) + ".address") diff --git a/config/config.env b/config/config.env index 7f7b406..d6258fb 100644 --- a/config/config.env +++ b/config/config.env @@ -83,6 +83,8 @@ HTTP_GW_CONNECT_TIMEOUT=5s HTTP_GW_REQUEST_TIMEOUT=5s # Interval to check nodes health. HTTP_GW_REBALANCE_TIMER=30s +# The number of errors on connection after which node is considered as unhealthy +S3_GW_POOL_ERROR_THRESHOLD=100 # Enable zip compression to download files by common prefix. HTTP_GW_ZIP_COMPRESSION=false diff --git a/config/config.yaml b/config/config.yaml index d3b5e9a..ef784ed 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -84,6 +84,7 @@ upload_header: connect_timeout: 5s # Timeout to dial node. request_timeout: 5s # Timeout to check node health during rebalance. rebalance_timer: 30s # Interval to check nodes health. +pool_error_threshold: 100 # The number of errors on connection after which node is considered as unhealthy. zip: compression: false # Enable zip compression to download files by common prefix. diff --git a/docs/gate-configuration.md b/docs/gate-configuration.md index 040ae1b..4661aa5 100644 --- a/docs/gate-configuration.md +++ b/docs/gate-configuration.md @@ -37,19 +37,21 @@ resolve_order: connect_timeout: 5s request_timeout: 5s -rebalance_timer: 30s +rebalance_timer: 30s +pool_error_threshold: 100 ``` -| Parameter | Type | Default value | Description | -|-------------------|------------|----------------|------------------------------------------------------------------------------------| -| `listen_address` | `string` | `0.0.0.0:8082` | The address that the gateway is listening on. | -| `tls_certificate` | `string` | | Path to the TLS certificate. | -| `tls_key` | `string` | | Path to the TLS key. | -| `rpc_endpoint` | `string` | | The address of the RPC host to which the gateway connects to resolve bucket names. | -| `resolve_order` | `[]string` | `[nns, dns]` | Order of bucket name resolvers to use. | -| `connect_timeout` | `duration` | `10s` | Timeout to connect to a node. | -| `request_timeout` | `duration` | `15s` | Timeout to check node health during rebalance. | -| `rebalance_timer` | `duration` | `60s` | Interval to check node health. | +| Parameter | Type | Default value | Description | +|------------------------|------------|----------------|------------------------------------------------------------------------------------| +| `listen_address` | `string` | `0.0.0.0:8082` | The address that the gateway is listening on. | +| `tls_certificate` | `string` | | Path to the TLS certificate. | +| `tls_key` | `string` | | Path to the TLS key. | +| `rpc_endpoint` | `string` | | The address of the RPC host to which the gateway connects to resolve bucket names. | +| `resolve_order` | `[]string` | `[nns, dns]` | Order of bucket name resolvers to use. | +| `connect_timeout` | `duration` | `10s` | Timeout to connect to a node. | +| `request_timeout` | `duration` | `15s` | Timeout to check node health during rebalance. | +| `rebalance_timer` | `duration` | `60s` | Interval to check node health. | +| `pool_error_threshold` | `uint32` | `100` | The number of errors on connection after which node is considered as unhealthy. | # `wallet` section diff --git a/settings.go b/settings.go index e99f701..c6ad084 100644 --- a/settings.go +++ b/settings.go @@ -22,6 +22,8 @@ const ( defaultShutdownTimeout = 15 * time.Second + defaultPoolErrorThreshold uint32 = 100 + cfgListenAddress = "listen_address" cfgTLSCertificate = "tls_certificate" cfgTLSKey = "tls_key" @@ -40,10 +42,11 @@ const ( cfgPprofEnabled = "pprof.enabled" cfgPprofAddress = "pprof.address" - // Timeouts. - cfgConTimeout = "connect_timeout" - cfgReqTimeout = "request_timeout" - cfgRebalance = "rebalance_timer" + // Pool config. + cfgConTimeout = "connect_timeout" + cfgReqTimeout = "request_timeout" + cfgRebalance = "rebalance_timer" + cfgPoolErrorThreshold = "pool_error_threshold" // Logger. cfgLoggerLevel = "logger.level" @@ -122,6 +125,9 @@ func settings() *viper.Viper { // logger: v.SetDefault(cfgLoggerLevel, "debug") + // pool: + v.SetDefault(cfgPoolErrorThreshold, defaultPoolErrorThreshold) + // web-server: v.SetDefault(cfgWebReadBufferSize, 4096) v.SetDefault(cfgWebWriteBufferSize, 4096)