978e0f1a26
If the cp command is executed with higher level of parallelism, it would open more connections to storage nodes at the same time. Therefore, the connection pool capacity should be expanded accordingly. The pool capacity is set to 100 * parallelism. Change-Id: Ia8b3ab6a99340d8cbb87a7b80c3354b2b21c1958
58 lines
1.4 KiB
Go
58 lines
1.4 KiB
Go
// Copyright (C) 2021 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
|
|
"storj.io/common/rpc"
|
|
"storj.io/common/rpc/rpcpool"
|
|
"storj.io/storj/cmd/uplink/ulext"
|
|
"storj.io/storj/cmd/uplink/ulfs"
|
|
"storj.io/uplink"
|
|
privateAccess "storj.io/uplink/private/access"
|
|
"storj.io/uplink/private/transport"
|
|
)
|
|
|
|
const uplinkCLIUserAgent = "uplink-cli"
|
|
|
|
func (ex *external) OpenFilesystem(ctx context.Context, accessName string, options ...ulext.Option) (ulfs.Filesystem, error) {
|
|
project, err := ex.OpenProject(ctx, accessName, options...)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ulfs.NewMixed(ulfs.NewLocal(), ulfs.NewRemote(project)), nil
|
|
}
|
|
|
|
func (ex *external) OpenProject(ctx context.Context, accessName string, options ...ulext.Option) (*uplink.Project, error) {
|
|
opts := ulext.LoadOptions(options...)
|
|
|
|
access, err := ex.OpenAccess(accessName)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
if opts.EncryptionBypass {
|
|
if err := privateAccess.EnablePathEncryptionBypass(access); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
config := uplink.Config{
|
|
UserAgent: uplinkCLIUserAgent,
|
|
}
|
|
|
|
if ex.quic {
|
|
transport.SetConnector(&config, rpc.NewHybridConnector())
|
|
}
|
|
|
|
if opts.ConnectionPoolOptions != (rpcpool.Options{}) {
|
|
if err := transport.SetConnectionPool(ctx, &config, rpcpool.New(opts.ConnectionPoolOptions)); err != nil {
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
return config.OpenProject(ctx, access)
|
|
}
|