Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config parameter to handle DefaultTimestamp #209

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading