Skip to content

Commit

Permalink
Merge pull request #209 from nspcc-dev/207-default-timestamp
Browse files Browse the repository at this point in the history
Add config parameter to handle `DefaultTimestamp`
  • Loading branch information
roman-khimov authored May 29, 2024
2 parents 1e4473a + b74eabc commit 49c7e66
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
56 changes: 31 additions & 25 deletions cmd/neofs-rest-gw/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,23 @@ const (

defaultShutdownTimeout = 15 * time.Second

defaultPoolErrorThreshold uint32 = 100
defaultPoolErrorThreshold uint32 = 100
defaultPoolDefaultTimestamp bool = false

// Pool config.
cmdNodeDialTimeout = "node-dial-timeout"
cfgNodeDialTimeout = "pool." + cmdNodeDialTimeout
cmdHealthcheckTimeout = "healthcheck-timeout"
cfgHealthcheckTimeout = "pool." + cmdHealthcheckTimeout
cmdRebalance = "rebalance-timer"
cfgRebalance = "pool." + cmdRebalance
cfgPoolErrorThreshold = "pool.error-threshold"
cmdPeers = "peers"
cfgPeers = "pool." + cmdPeers
cfgPeerAddress = "address"
cfgPeerPriority = "priority"
cfgPeerWeight = "weight"
cmdNodeDialTimeout = "node-dial-timeout"
cfgNodeDialTimeout = "pool." + cmdNodeDialTimeout
cmdHealthcheckTimeout = "healthcheck-timeout"
cfgHealthcheckTimeout = "pool." + cmdHealthcheckTimeout
cmdRebalance = "rebalance-timer"
cfgRebalance = "pool." + cmdRebalance
cfgPoolErrorThreshold = "pool.error-threshold"
cfgPoolDefaultTimestamp = "pool.default-timestamp"
cmdPeers = "peers"
cfgPeers = "pool." + cmdPeers
cfgPeerAddress = "address"
cfgPeerPriority = "priority"
cfgPeerWeight = "weight"

// Metrics / Profiler.
cfgPrometheusEnabled = "prometheus.enabled"
Expand Down Expand Up @@ -153,6 +155,7 @@ func config() *viper.Viper {
// set defaults:
// pool
v.SetDefault(cfgPoolErrorThreshold, defaultPoolErrorThreshold)
v.SetDefault(cfgPoolDefaultTimestamp, defaultPoolDefaultTimestamp)

// metrics
v.SetDefault(cfgPprofAddress, "localhost:8091")
Expand Down Expand Up @@ -269,18 +272,19 @@ var bindings = map[string]string{
}

var knownConfigParams = map[string]struct{}{
cfgWalletAddress: {},
cfgWalletPath: {},
cfgWalletPassphrase: {},
cfgRebalance: {},
cfgHealthcheckTimeout: {},
cfgNodeDialTimeout: {},
cfgPoolErrorThreshold: {},
cfgLoggerLevel: {},
cfgPrometheusEnabled: {},
cfgPrometheusAddress: {},
cfgPprofEnabled: {},
cfgPprofAddress: {},
cfgWalletAddress: {},
cfgWalletPath: {},
cfgWalletPassphrase: {},
cfgRebalance: {},
cfgHealthcheckTimeout: {},
cfgNodeDialTimeout: {},
cfgPoolErrorThreshold: {},
cfgPoolDefaultTimestamp: {},
cfgLoggerLevel: {},
cfgPrometheusEnabled: {},
cfgPrometheusAddress: {},
cfgPprofEnabled: {},
cfgPprofAddress: {},
}

func validateConfig(cfg *viper.Viper, logger *zap.Logger) {
Expand Down Expand Up @@ -576,6 +580,8 @@ func newNeofsAPI(ctx context.Context, logger *zap.Logger, v *viper.Viper) (*hand
apiPrm.ServiceShutdownTimeout = defaultShutdownTimeout
apiPrm.MaxObjectSize = int64(ni.MaxObjectSize())

apiPrm.DefaultTimestamp = v.GetBool(cfgPoolDefaultTimestamp)

return handlers.NewAPI(&apiPrm), nil
}

Expand Down
2 changes: 2 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ pool:
rebalance-timer: 30s
# The number of errors on connection after which node is considered as unhealthy.
error-threshold: 100
# By default, add a Timestamp to the object upon creation.
default-timestamp: false

# Nodes configuration.
# This configuration make gateway use the first node (grpc://s01.neofs.devenv:8080)
Expand Down
1 change: 1 addition & 0 deletions docs/gate-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ pool:
| `healthcheck-timeout` | `duration` | `15s` | Timeout to check node health during rebalance. |
| `rebalance-timer` | `duration` | `60s` | Interval to check node health. |
| `error-threshold` | `uint32` | `100` | The number of errors on connection after which node is considered as unhealthy. |
| `default-timestamp` | `bool` | `false` | By default, add a Timestamp to the object upon creation. | |

## `peers` section

Expand Down

0 comments on commit 49c7e66

Please sign in to comment.