Some checks failed
test / lint (pull_request) Failing after 1m4s
test / Linux Go 1.19.x (pull_request) Failing after 3m1s
test / docker (pull_request) Failing after 4m33s
test / Linux Go 1.22.x (pull_request) Failing after 4m40s
test / Cross Compile for subset 1/3 (pull_request) Successful in 5m43s
test / Linux Go 1.20.x (pull_request) Failing after 6m17s
test / Cross Compile for subset 2/3 (pull_request) Failing after 6m32s
test / Linux Go 1.21.x (pull_request) Failing after 6m45s
test / Cross Compile for subset 0/3 (pull_request) Successful in 9m21s
test / Linux (race) Go 1.22.x (pull_request) Failing after 12m36s
test / Windows Go 1.22.x (pull_request) Has been cancelled
test / macOS Go 1.22.x (pull_request) Has been cancelled
test / Analyze results (pull_request) Has been cancelled
Signed-off-by: Aleksey Kravchenko <al.kravchenko@yadro.com>
56 lines
1.6 KiB
Go
56 lines
1.6 KiB
Go
package frostfs
|
|
|
|
import (
|
|
"net/url"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/restic/restic/internal/errors"
|
|
"github.com/restic/restic/internal/options"
|
|
)
|
|
|
|
// Config contains all configuration necessary to connect to neofs.
|
|
type Config struct {
|
|
Endpoint string
|
|
Container string
|
|
|
|
Wallet string `option:"wallet" help:"path to the wallet"`
|
|
Address string `option:"address" help:"address of account (can be empty)"`
|
|
Password string `option:"password" help:"password to decrypt wallet"`
|
|
Timeout time.Duration `option:"timeout" help:"timeout to connect and request (default 10s)"`
|
|
RebalanceInterval time.Duration `option:"rebalance" help:"interval between checking node healthy (default 15s)"`
|
|
|
|
Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"`
|
|
}
|
|
|
|
// NewConfig returns a new Config with the default values filled in.
|
|
func NewConfig() Config {
|
|
return Config{
|
|
Connections: 5,
|
|
}
|
|
}
|
|
|
|
func init() {
|
|
options.Register("frostfs", Config{})
|
|
}
|
|
|
|
// ParseConfig parses the string s and extracts the frostfs config.
|
|
// The configuration format is frostfs:grpcs://s01.frostfs.devenv:8080/container,
|
|
// where 'container' is container name or container id.
|
|
func ParseConfig(s string) (*Config, error) {
|
|
if !strings.HasPrefix(s, "frostfs:") {
|
|
return nil, errors.New("frostfs: invalid format")
|
|
}
|
|
|
|
// strip prefix "frostfs:"
|
|
s = s[8:]
|
|
u, err := url.Parse(s)
|
|
if err != nil {
|
|
return nil, errors.Wrap(err, "url.Parse")
|
|
}
|
|
|
|
cfg := NewConfig()
|
|
cfg.Container = strings.TrimPrefix(u.Path, "/")
|
|
cfg.Endpoint = strings.TrimSuffix(s, u.Path)
|
|
return &cfg, nil
|
|
}
|