sftp: Limit concurrent backend operations

This commit is contained in:
Michael Eischer
2021-08-07 19:56:59 +02:00
parent cd783358d3
commit ece06f125e
6 changed files with 112 additions and 41 deletions

View File

@@ -15,6 +15,15 @@ type Config struct {
Layout string `option:"layout" help:"use this backend directory layout (default: auto-detect)"`
Command string `option:"command" help:"specify command to create sftp connection"`
Connections uint `option:"connections" help:"set a limit for the number of concurrent connections (default: 5)"`
}
// NewConfig returns a new config with default options applied.
func NewConfig() Config {
return Config{
Connections: 5,
}
}
func init() {
@@ -75,10 +84,11 @@ func ParseConfig(s string) (interface{}, error) {
return nil, errors.Fatal("sftp path starts with the tilde (~) character, that fails for most sftp servers.\nUse a relative directory, most servers interpret this as relative to the user's home directory.")
}
return Config{
User: user,
Host: host,
Port: port,
Path: p,
}, nil
cfg := NewConfig()
cfg.User = user
cfg.Host = host
cfg.Port = port
cfg.Path = p
return cfg, nil
}