forked from TrueCloudLab/frostfs-node
[#1255] node/config: Add persistent storage
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
016eaa25f3
commit
9cda3121ab
5 changed files with 37 additions and 5 deletions
|
@ -12,6 +12,12 @@ import (
|
||||||
utilConfig "github.com/nspcc-dev/neofs-node/pkg/util/config"
|
utilConfig "github.com/nspcc-dev/neofs-node/pkg/util/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// PersistentSessionsConfig is a wrapper over "persistent_sessions" config section
|
||||||
|
// which provides access to persistent session tokens storage configuration of node.
|
||||||
|
type PersistentSessionsConfig struct {
|
||||||
|
cfg *config.Config
|
||||||
|
}
|
||||||
|
|
||||||
// PersistentStateConfig is a wrapper over "persistent_state" config section
|
// PersistentStateConfig is a wrapper over "persistent_state" config section
|
||||||
// which provides access to persistent state storage configuration of node.
|
// which provides access to persistent state storage configuration of node.
|
||||||
type PersistentStateConfig struct {
|
type PersistentStateConfig struct {
|
||||||
|
@ -26,6 +32,7 @@ type NotificationConfig struct {
|
||||||
|
|
||||||
const (
|
const (
|
||||||
subsection = "node"
|
subsection = "node"
|
||||||
|
persistentSessionsSubsection = "persistent_sessions"
|
||||||
persistentStateSubsection = "persistent_state"
|
persistentStateSubsection = "persistent_state"
|
||||||
notificationSubsection = "notification"
|
notificationSubsection = "notification"
|
||||||
|
|
||||||
|
@ -137,6 +144,21 @@ func Relay(c *config.Config) bool {
|
||||||
return config.BoolSafe(c.Sub(subsection), "relay")
|
return config.BoolSafe(c.Sub(subsection), "relay")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PersistentSessions returns structure that provides access to "persistent_sessions"
|
||||||
|
// subsection of "node" section.
|
||||||
|
func PersistentSessions(c *config.Config) PersistentSessionsConfig {
|
||||||
|
return PersistentSessionsConfig{
|
||||||
|
c.Sub(subsection).Sub(persistentSessionsSubsection),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Path returns value of "path" config parameter.
|
||||||
|
//
|
||||||
|
// Returns PersistentStatePathDefault if value is not a non-empty string.
|
||||||
|
func (p PersistentSessionsConfig) Path() string {
|
||||||
|
return config.String(p.cfg, "path")
|
||||||
|
}
|
||||||
|
|
||||||
// PersistentState returns structure that provides access to "persistent_state"
|
// PersistentState returns structure that provides access to "persistent_state"
|
||||||
// subsection of "node" section.
|
// subsection of "node" section.
|
||||||
func PersistentState(c *config.Config) PersistentStateConfig {
|
func PersistentState(c *config.Config) PersistentStateConfig {
|
||||||
|
|
|
@ -31,6 +31,7 @@ func TestNodeSection(t *testing.T) {
|
||||||
|
|
||||||
attribute := Attributes(empty)
|
attribute := Attributes(empty)
|
||||||
relay := Relay(empty)
|
relay := Relay(empty)
|
||||||
|
persisessionsPath := PersistentSessions(empty).Path()
|
||||||
persistatePath := PersistentState(empty).Path()
|
persistatePath := PersistentState(empty).Path()
|
||||||
notificationDefaultEnabled := Notification(empty).Enabled()
|
notificationDefaultEnabled := Notification(empty).Enabled()
|
||||||
notificationDefaultEndpoint := Notification(empty).Endpoint()
|
notificationDefaultEndpoint := Notification(empty).Endpoint()
|
||||||
|
@ -42,6 +43,7 @@ func TestNodeSection(t *testing.T) {
|
||||||
|
|
||||||
require.Empty(t, attribute)
|
require.Empty(t, attribute)
|
||||||
require.Equal(t, false, relay)
|
require.Equal(t, false, relay)
|
||||||
|
require.Equal(t, "", persisessionsPath)
|
||||||
require.Equal(t, PersistentStatePathDefault, persistatePath)
|
require.Equal(t, PersistentStatePathDefault, persistatePath)
|
||||||
require.Equal(t, false, notificationDefaultEnabled)
|
require.Equal(t, false, notificationDefaultEnabled)
|
||||||
require.Equal(t, "", notificationDefaultEndpoint)
|
require.Equal(t, "", notificationDefaultEndpoint)
|
||||||
|
@ -74,6 +76,7 @@ func TestNodeSection(t *testing.T) {
|
||||||
attributes := Attributes(c)
|
attributes := Attributes(c)
|
||||||
relay := Relay(c)
|
relay := Relay(c)
|
||||||
wKey := Wallet(c)
|
wKey := Wallet(c)
|
||||||
|
persisessionsPath := PersistentSessions(c).Path()
|
||||||
persistatePath := PersistentState(c).Path()
|
persistatePath := PersistentState(c).Path()
|
||||||
notificationEnabled := Notification(c).Enabled()
|
notificationEnabled := Notification(c).Enabled()
|
||||||
notificationEndpoint := Notification(c).Endpoint()
|
notificationEndpoint := Notification(c).Endpoint()
|
||||||
|
@ -134,6 +137,7 @@ func TestNodeSection(t *testing.T) {
|
||||||
config.StringSafe(c.Sub("node").Sub("wallet"), "address"),
|
config.StringSafe(c.Sub("node").Sub("wallet"), "address"),
|
||||||
address.Uint160ToString(wKey.GetScriptHash()))
|
address.Uint160ToString(wKey.GetScriptHash()))
|
||||||
|
|
||||||
|
require.Equal(t, "/sessions", persisessionsPath)
|
||||||
require.Equal(t, "/state", persistatePath)
|
require.Equal(t, "/state", persistatePath)
|
||||||
require.Equal(t, true, notificationEnabled)
|
require.Equal(t, true, notificationEnabled)
|
||||||
require.Equal(t, "tls://localhost:4222", notificationEndpoint)
|
require.Equal(t, "tls://localhost:4222", notificationEndpoint)
|
||||||
|
|
|
@ -15,6 +15,7 @@ NEOFS_NODE_ADDRESSES="s01.neofs.devenv:8080 /dns4/s02.neofs.devenv/tcp/8081 grpc
|
||||||
NEOFS_NODE_ATTRIBUTE_0=Price:11
|
NEOFS_NODE_ATTRIBUTE_0=Price:11
|
||||||
NEOFS_NODE_ATTRIBUTE_1="UN-LOCODE:RU MSK"
|
NEOFS_NODE_ATTRIBUTE_1="UN-LOCODE:RU MSK"
|
||||||
NEOFS_NODE_RELAY=true
|
NEOFS_NODE_RELAY=true
|
||||||
|
NEOFS_NODE_PERSISTENT_SESSIONS_PATH=/sessions
|
||||||
NEOFS_NODE_PERSISTENT_STATE_PATH=/state
|
NEOFS_NODE_PERSISTENT_STATE_PATH=/state
|
||||||
NEOFS_NODE_SUBNET_EXIT_ZERO=true
|
NEOFS_NODE_SUBNET_EXIT_ZERO=true
|
||||||
NEOFS_NODE_SUBNET_ENTRIES=123 456 789
|
NEOFS_NODE_SUBNET_ENTRIES=123 456 789
|
||||||
|
|
|
@ -26,6 +26,9 @@
|
||||||
"attribute_0": "Price:11",
|
"attribute_0": "Price:11",
|
||||||
"attribute_1": "UN-LOCODE:RU MSK",
|
"attribute_1": "UN-LOCODE:RU MSK",
|
||||||
"relay": true,
|
"relay": true,
|
||||||
|
"persistent_sessions": {
|
||||||
|
"path": "/sessions"
|
||||||
|
},
|
||||||
"persistent_state": {
|
"persistent_state": {
|
||||||
"path": "/state"
|
"path": "/state"
|
||||||
},
|
},
|
||||||
|
|
|
@ -23,8 +23,10 @@ node:
|
||||||
attribute_0: "Price:11"
|
attribute_0: "Price:11"
|
||||||
attribute_1: UN-LOCODE:RU MSK
|
attribute_1: UN-LOCODE:RU MSK
|
||||||
relay: true # start Storage node in relay mode without bootstrapping into the Network map
|
relay: true # start Storage node in relay mode without bootstrapping into the Network map
|
||||||
persistent_state: # path to persistent state file of Storage node
|
persistent_sessions:
|
||||||
path: /state
|
path: /sessions # path to persistent session tokens file of Storage node
|
||||||
|
persistent_state:
|
||||||
|
path: /state # path to persistent state file of Storage node
|
||||||
subnet:
|
subnet:
|
||||||
exit_zero: true # toggle entrance to zero subnet (overrides corresponding attribute and occurrence in `entries`)
|
exit_zero: true # toggle entrance to zero subnet (overrides corresponding attribute and occurrence in `entries`)
|
||||||
entries: # list of IDs of subnets to enter in a text format of NeoFS API protocol (overrides corresponding attributes)
|
entries: # list of IDs of subnets to enter in a text format of NeoFS API protocol (overrides corresponding attributes)
|
||||||
|
|
Loading…
Reference in a new issue