Merge pull request #3795 from greatroar/sema

backend: Move semaphores to a dedicated package
This commit is contained in:
MichaelEischer 2022-06-18 17:12:01 +02:00 committed by GitHub
commit 307f14604f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 101 additions and 98 deletions

View file

@ -14,6 +14,7 @@ import (
"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"
@ -26,7 +27,7 @@ import (
type beSwift struct {
conn *swift.Connection
connections uint
sem *backend.Semaphore
sem sema.Semaphore
container string // Container name
prefix string // Prefix of object names in the container
backend.Layout
@ -40,7 +41,7 @@ var _ restic.Backend = &beSwift{}
func Open(ctx context.Context, cfg Config, rt http.RoundTripper) (restic.Backend, error) {
debug.Log("config %#v", cfg)
sem, err := backend.NewSemaphore(cfg.Connections)
sem, err := sema.New(cfg.Connections)
if err != nil {
return nil, err
}