From 408d914347e5665b1057baea00d1ed33aa55c27d Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Tue, 15 Nov 2022 18:06:53 +0300 Subject: [PATCH] [#234] Update SDK to support timeout for stream Signed-off-by: Denis Kirillov --- CHANGELOG.md | 1 + app.go | 1 + config/config.env | 2 ++ config/config.yaml | 1 + docs/gate-configuration.md | 2 ++ go.mod | 2 +- go.sum | 4 ++-- settings.go | 3 +++ 8 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdb0867..3b682d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This document outlines major changes between releases. ### Added - Support the `Date` header on upload (#214) +- Timeout for individual operations in streaming RPC (#234) ## [0.25.0] - 2022-10-31 diff --git a/app.go b/app.go index 7cc84cc..8e72555 100644 --- a/app.go +++ b/app.go @@ -137,6 +137,7 @@ func newApp(ctx context.Context, opt ...Option) App { var prm pool.InitParameters prm.SetKey(key) prm.SetNodeDialTimeout(a.cfg.GetDuration(cfgConTimeout)) + prm.SetNodeStreamTimeout(a.cfg.GetDuration(cfgStreamTimeout)) prm.SetHealthcheckTimeout(a.cfg.GetDuration(cfgReqTimeout)) prm.SetClientRebalanceInterval(a.cfg.GetDuration(cfgRebalance)) prm.SetErrorThreshold(a.cfg.GetUint32(cfgPoolErrorThreshold)) diff --git a/config/config.env b/config/config.env index d6258fb..b66dae0 100644 --- a/config/config.env +++ b/config/config.env @@ -79,6 +79,8 @@ HTTP_GW_UPLOAD_HEADER_USE_DEFAULT_TIMESTAMP=false # Timeout to dial node. HTTP_GW_CONNECT_TIMEOUT=5s +# Timeout for individual operations in streaming RPC. +HTTP_GW_STREAM_TIMEOUT=10s # Timeout to check node health during rebalance. HTTP_GW_REQUEST_TIMEOUT=5s # Interval to check nodes health. diff --git a/config/config.yaml b/config/config.yaml index ef784ed..38a9ff0 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -82,6 +82,7 @@ upload_header: use_default_timestamp: false # Create timestamp for object if it isn't provided by header. connect_timeout: 5s # Timeout to dial node. +stream_timeout: 10s # Timeout for individual operations in streaming RPC. 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. diff --git a/docs/gate-configuration.md b/docs/gate-configuration.md index 7812fb3..2a69a1a 100644 --- a/docs/gate-configuration.md +++ b/docs/gate-configuration.md @@ -66,6 +66,7 @@ resolve_order: - dns connect_timeout: 5s +stream_timeout: 10s request_timeout: 5s rebalance_timer: 30s pool_error_threshold: 100 @@ -79,6 +80,7 @@ pool_error_threshold: 100 | `rpc_endpoint` | `string` | yes | | The address of the RPC host to which the gateway connects to resolve bucket names. | | `resolve_order` | `[]string` | yes | `[nns, dns]` | Order of bucket name resolvers to use. | | `connect_timeout` | `duration` | | `10s` | Timeout to connect to a node. | +| `stream_timeout` | `duration` | | `10s` | Timeout for individual operations in streaming RPC. | | `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. | diff --git a/go.mod b/go.mod index d76778f..87d1dc4 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/fasthttp/router v1.4.1 github.com/nspcc-dev/neo-go v0.99.4 github.com/nspcc-dev/neofs-api-go/v2 v2.14.0 - github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.7.0.20221114144617-d047289182a1 + github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.7.0.20221115140820-b4b07a3c4e11 github.com/prometheus/client_golang v1.13.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.8.1 diff --git a/go.sum b/go.sum index 991aa8e..a4e3530 100644 --- a/go.sum +++ b/go.sum @@ -766,8 +766,8 @@ github.com/nspcc-dev/neofs-crypto v0.4.0 h1:5LlrUAM5O0k1+sH/sktBtrgfWtq1pgpDs09f github.com/nspcc-dev/neofs-crypto v0.4.0/go.mod h1:6XJ8kbXgOfevbI2WMruOtI+qUJXNwSGM/E9eClXxPHs= github.com/nspcc-dev/neofs-sdk-go v0.0.0-20211201182451-a5b61c4f6477/go.mod h1:dfMtQWmBHYpl9Dez23TGtIUKiFvCIxUZq/CkSIhEpz4= github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659/go.mod h1:/jay1lr3w7NQd/VDBkEhkJmDmyPNsu4W+QV2obsUV40= -github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.7.0.20221114144617-d047289182a1 h1:SAB+pu0aXXxOsBxBNZG9F5c1YLCpSAW5HhBI5Id43d8= -github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.7.0.20221114144617-d047289182a1/go.mod h1:7bH8zabbewpXstaXKoV0Tk3lV7KFYadi5edLU5yDERY= +github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.7.0.20221115140820-b4b07a3c4e11 h1:dcofGaVR6najaIdh0JOXoxqV1MLJWnJ3pPMhD5gowV4= +github.com/nspcc-dev/neofs-sdk-go v1.0.0-rc.7.0.20221115140820-b4b07a3c4e11/go.mod h1:7bH8zabbewpXstaXKoV0Tk3lV7KFYadi5edLU5yDERY= github.com/nspcc-dev/rfc6979 v0.1.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE= github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso= diff --git a/settings.go b/settings.go index e687141..b042ab5 100644 --- a/settings.go +++ b/settings.go @@ -21,6 +21,7 @@ const ( defaultRebalanceTimer = 60 * time.Second defaultRequestTimeout = 15 * time.Second defaultConnectTimeout = 10 * time.Second + defaultStreamTimeout = 10 * time.Second defaultShutdownTimeout = 15 * time.Second @@ -46,6 +47,7 @@ const ( // Pool config. cfgConTimeout = "connect_timeout" + cfgStreamTimeout = "stream_timeout" cfgReqTimeout = "request_timeout" cfgRebalance = "rebalance_timer" cfgPoolErrorThreshold = "pool_error_threshold" @@ -112,6 +114,7 @@ func settings() *viper.Viper { flags.String(cmdAddress, "", `address of wallet account`) flags.String(cmdConfig, "", "config path") flags.Duration(cfgConTimeout, defaultConnectTimeout, "gRPC connect timeout") + flags.Duration(cfgStreamTimeout, defaultStreamTimeout, "gRPC individual message timeout") flags.Duration(cfgReqTimeout, defaultRequestTimeout, "gRPC request timeout") flags.Duration(cfgRebalance, defaultRebalanceTimer, "gRPC connection rebalance timer")