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:
parent
1dd4b9b60e
commit
910d917b71
11 changed files with 101 additions and 98 deletions
|
@ -17,6 +17,7 @@ import (
|
|||
"golang.org/x/net/context/ctxhttp"
|
||||
|
||||
"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"
|
||||
|
@ -31,7 +32,7 @@ var _ restic.Backend = &Backend{}
|
|||
type Backend struct {
|
||||
url *url.URL
|
||||
connections uint
|
||||
sem *backend.Semaphore
|
||||
sem sema.Semaphore
|
||||
client *http.Client
|
||||
backend.Layout
|
||||
}
|
||||
|
@ -46,7 +47,7 @@ const (
|
|||
func Open(cfg Config, rt http.RoundTripper) (*Backend, error) {
|
||||
client := &http.Client{Transport: rt}
|
||||
|
||||
sem, err := backend.NewSemaphore(cfg.Connections)
|
||||
sem, err := sema.New(cfg.Connections)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue