forked from TrueCloudLab/frostfs-node
[#1170] config: Delete notification endpoints
Also, change `http` to `ws` in examples. Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
3e45b4a085
commit
fdf1338d65
7 changed files with 2 additions and 56 deletions
|
@ -48,13 +48,9 @@ func defaultConfiguration(cfg *viper.Viper) {
|
||||||
cfg.SetDefault("node.persistent_state.path", ".neofs-ir-state")
|
cfg.SetDefault("node.persistent_state.path", ".neofs-ir-state")
|
||||||
|
|
||||||
cfg.SetDefault("morph.endpoint.client", "")
|
cfg.SetDefault("morph.endpoint.client", "")
|
||||||
cfg.SetDefault("morph.endpoint.notification", "")
|
|
||||||
cfg.SetDefault("morph.dial_timeout", "10s")
|
|
||||||
cfg.SetDefault("morph.validators", []string{})
|
cfg.SetDefault("morph.validators", []string{})
|
||||||
|
|
||||||
cfg.SetDefault("mainnet.endpoint.client", "")
|
cfg.SetDefault("mainnet.endpoint.client", "")
|
||||||
cfg.SetDefault("mainnet.endpoint.notification", "")
|
|
||||||
cfg.SetDefault("mainnet.dial_timeout", "10s")
|
|
||||||
|
|
||||||
cfg.SetDefault("wallet.path", "") // inner ring node NEP-6 wallet
|
cfg.SetDefault("wallet.path", "") // inner ring node NEP-6 wallet
|
||||||
cfg.SetDefault("wallet.address", "") // account address
|
cfg.SetDefault("wallet.address", "") // account address
|
||||||
|
|
|
@ -37,19 +37,6 @@ func RPCEndpoint(c *config.Config) []string {
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotificationEndpoint returns list of values of "notification_endpoint" config
|
|
||||||
// parameter from "morph" section.
|
|
||||||
//
|
|
||||||
// Throws panic if list is empty.
|
|
||||||
func NotificationEndpoint(c *config.Config) []string {
|
|
||||||
v := config.StringSliceSafe(c.Sub(subsection), "notification_endpoint")
|
|
||||||
if len(v) == 0 {
|
|
||||||
panic(fmt.Errorf("no morph chain notification endpoints, see `morph.notification_endpoint` section"))
|
|
||||||
}
|
|
||||||
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
|
|
||||||
// DialTimeout returns value of "dial_timeout" config parameter
|
// DialTimeout returns value of "dial_timeout" config parameter
|
||||||
// from "morph" section.
|
// from "morph" section.
|
||||||
//
|
//
|
||||||
|
@ -68,14 +55,3 @@ func DialTimeout(c *config.Config) time.Duration {
|
||||||
func DisableCache(c *config.Config) bool {
|
func DisableCache(c *config.Config) bool {
|
||||||
return config.BoolSafe(c.Sub(subsection), "disable_cache")
|
return config.BoolSafe(c.Sub(subsection), "disable_cache")
|
||||||
}
|
}
|
||||||
|
|
||||||
// MaxConnPerHost return value of "max_connections_per_host" config
|
|
||||||
// parameter from "morph" section.
|
|
||||||
func MaxConnPerHost(c *config.Config) int {
|
|
||||||
v := config.Uint32Safe(c.Sub(subsection), "max_connections_per_host")
|
|
||||||
if v > 0 {
|
|
||||||
return int(v)
|
|
||||||
}
|
|
||||||
|
|
||||||
return MaxConnPerHostDefault
|
|
||||||
}
|
|
||||||
|
|
|
@ -15,21 +15,14 @@ func TestMorphSection(t *testing.T) {
|
||||||
empty := configtest.EmptyConfig()
|
empty := configtest.EmptyConfig()
|
||||||
|
|
||||||
require.Panics(t, func() { morphconfig.RPCEndpoint(empty) })
|
require.Panics(t, func() { morphconfig.RPCEndpoint(empty) })
|
||||||
require.Panics(t, func() { morphconfig.NotificationEndpoint(empty) })
|
|
||||||
require.Equal(t, morphconfig.DialTimeoutDefault, morphconfig.DialTimeout(empty))
|
require.Equal(t, morphconfig.DialTimeoutDefault, morphconfig.DialTimeout(empty))
|
||||||
require.Equal(t, false, morphconfig.DisableCache(empty))
|
require.Equal(t, false, morphconfig.DisableCache(empty))
|
||||||
require.Equal(t, 10, morphconfig.MaxConnPerHost(empty))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
const path = "../../../../config/example/node"
|
const path = "../../../../config/example/node"
|
||||||
|
|
||||||
var (
|
var (
|
||||||
rpcs = []string{
|
rpcs = []string{
|
||||||
"https://rpc1.morph.fs.neo.org:40341",
|
|
||||||
"https://rpc2.morph.fs.neo.org:40341",
|
|
||||||
}
|
|
||||||
|
|
||||||
wss = []string{
|
|
||||||
"wss://rpc1.morph.fs.neo.org:40341/ws",
|
"wss://rpc1.morph.fs.neo.org:40341/ws",
|
||||||
"wss://rpc2.morph.fs.neo.org:40341/ws",
|
"wss://rpc2.morph.fs.neo.org:40341/ws",
|
||||||
}
|
}
|
||||||
|
@ -37,10 +30,8 @@ func TestMorphSection(t *testing.T) {
|
||||||
|
|
||||||
var fileConfigTest = func(c *config.Config) {
|
var fileConfigTest = func(c *config.Config) {
|
||||||
require.Equal(t, rpcs, morphconfig.RPCEndpoint(c))
|
require.Equal(t, rpcs, morphconfig.RPCEndpoint(c))
|
||||||
require.Equal(t, wss, morphconfig.NotificationEndpoint(c))
|
|
||||||
require.Equal(t, 30*time.Second, morphconfig.DialTimeout(c))
|
require.Equal(t, 30*time.Second, morphconfig.DialTimeout(c))
|
||||||
require.Equal(t, true, morphconfig.DisableCache(c))
|
require.Equal(t, true, morphconfig.DisableCache(c))
|
||||||
require.Equal(t, 11, morphconfig.MaxConnPerHost(c))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
configtest.ForEachFileType(path, fileConfigTest)
|
configtest.ForEachFileType(path, fileConfigTest)
|
||||||
|
|
|
@ -55,9 +55,7 @@ NEOFS_CONTRACTS_PROXY=ad7c6b55b737b696e5c82c85445040964a03e97f
|
||||||
# Morph chain section
|
# Morph chain section
|
||||||
NEOFS_MORPH_DIAL_TIMEOUT=30s
|
NEOFS_MORPH_DIAL_TIMEOUT=30s
|
||||||
NEOFS_MORPH_DISABLE_CACHE=true
|
NEOFS_MORPH_DISABLE_CACHE=true
|
||||||
NEOFS_MORPH_RPC_ENDPOINT="https://rpc1.morph.fs.neo.org:40341 https://rpc2.morph.fs.neo.org:40341"
|
NEOFS_MORPH_RPC_ENDPOINT="wss://rpc1.morph.fs.neo.org:40341/ws wss://rpc2.morph.fs.neo.org:40341/ws"
|
||||||
NEOFS_MORPH_NOTIFICATION_ENDPOINT="wss://rpc1.morph.fs.neo.org:40341/ws wss://rpc2.morph.fs.neo.org:40341/ws"
|
|
||||||
NEOFS_MORPH_MAX_CONNECTIONS_PER_HOST=11
|
|
||||||
|
|
||||||
# Main chain section (optional)
|
# Main chain section (optional)
|
||||||
NEOFS_MAINCHAIN_DIAL_TIMEOUT=30s
|
NEOFS_MAINCHAIN_DIAL_TIMEOUT=30s
|
||||||
|
|
|
@ -94,14 +94,9 @@
|
||||||
"dial_timeout": "30s",
|
"dial_timeout": "30s",
|
||||||
"disable_cache": true,
|
"disable_cache": true,
|
||||||
"rpc_endpoint": [
|
"rpc_endpoint": [
|
||||||
"https://rpc1.morph.fs.neo.org:40341",
|
|
||||||
"https://rpc2.morph.fs.neo.org:40341"
|
|
||||||
],
|
|
||||||
"notification_endpoint": [
|
|
||||||
"wss://rpc1.morph.fs.neo.org:40341/ws",
|
"wss://rpc1.morph.fs.neo.org:40341/ws",
|
||||||
"wss://rpc2.morph.fs.neo.org:40341/ws"
|
"wss://rpc2.morph.fs.neo.org:40341/ws"
|
||||||
],
|
]
|
||||||
"max_connections_per_host": 11
|
|
||||||
},
|
},
|
||||||
"mainchain": {
|
"mainchain": {
|
||||||
"dial_timeout": "30s",
|
"dial_timeout": "30s",
|
||||||
|
|
|
@ -79,12 +79,8 @@ morph:
|
||||||
dial_timeout: 30s # timeout for side chain NEO RPC client connection
|
dial_timeout: 30s # timeout for side chain NEO RPC client connection
|
||||||
disable_cache: true # do not use TTL cache for side chain GET operations
|
disable_cache: true # do not use TTL cache for side chain GET operations
|
||||||
rpc_endpoint: # side chain NEO RPC endpoints; are shuffled and used one by one until the first success
|
rpc_endpoint: # side chain NEO RPC endpoints; are shuffled and used one by one until the first success
|
||||||
- https://rpc1.morph.fs.neo.org:40341
|
|
||||||
- https://rpc2.morph.fs.neo.org:40341
|
|
||||||
notification_endpoint: # side chain NEO RPC notification endpoints; are shuffled and used only the first non-error one
|
|
||||||
- wss://rpc1.morph.fs.neo.org:40341/ws
|
- wss://rpc1.morph.fs.neo.org:40341/ws
|
||||||
- wss://rpc2.morph.fs.neo.org:40341/ws
|
- wss://rpc2.morph.fs.neo.org:40341/ws
|
||||||
max_connections_per_host: 11 # maximum of open connections per one host
|
|
||||||
|
|
||||||
mainchain: # DEPRECATED section, is not used and not read
|
mainchain: # DEPRECATED section, is not used and not read
|
||||||
dial_timeout: 30s # timeout for main chain NEO RPC client connection
|
dial_timeout: 30s # timeout for main chain NEO RPC client connection
|
||||||
|
|
|
@ -921,12 +921,6 @@ func New(ctx context.Context, log *zap.Logger, cfg *viper.Viper) (*Server, error
|
||||||
}
|
}
|
||||||
|
|
||||||
func createListener(ctx context.Context, cli *client.Client, p *chainParams) (event.Listener, error) {
|
func createListener(ctx context.Context, cli *client.Client, p *chainParams) (event.Listener, error) {
|
||||||
// config name left unchanged for compatibility, may be its better to rename it to "endpoints"
|
|
||||||
endpoints := p.cfg.GetStringSlice(p.name + ".endpoint.notification")
|
|
||||||
if len(endpoints) == 0 {
|
|
||||||
return nil, errors.New("missing morph notification endpoints")
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
sub subscriber.Subscriber
|
sub subscriber.Subscriber
|
||||||
err error
|
err error
|
||||||
|
|
Loading…
Reference in a new issue