backend: Move semaphores to a dedicated package

... called backend/sema. I resisted the temptation to call the main
type sema.Phore. Also, semaphores are now passed by value to skip a
level of indirection when using them.
This commit is contained in:
greatroar 2022-06-12 17:45:34 +02:00
parent 1dd4b9b60e
commit 910d917b71
11 changed files with 101 additions and 98 deletions

View file

@ -13,12 +13,12 @@ import (
"path"
"time"
"github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/backend/sema"
"github.com/restic/restic/internal/debug"
"github.com/restic/restic/internal/errors"
"github.com/restic/restic/internal/restic"
"github.com/restic/restic/internal/backend"
"github.com/restic/restic/internal/debug"
"github.com/cenkalti/backoff/v4"
"github.com/pkg/sftp"
)
@ -33,7 +33,7 @@ type SFTP struct {
posixRename bool
sem *backend.Semaphore
sem sema.Semaphore
backend.Layout
Config
backend.Modes
@ -121,7 +121,7 @@ func (r *SFTP) clientError() error {
func Open(ctx context.Context, cfg Config) (*SFTP, error) {
debug.Log("open backend with config %#v", cfg)
sem, err := backend.NewSemaphore(cfg.Connections)
sem, err := sema.New(cfg.Connections)
if err != nil {
return nil, err
}