mirror of
https://github.com/kopia/kopia.git
synced 2026-01-24 14:28:06 -05:00
Supported are:
```
$ kopia throttle set \
--download-bytes-per-second=N | unlimited
--upload-bytes-per-second=N | unlimited
--read-requests-per-second=N | unlimited
--write-requests-per-second=N | unlimited
--list-requests-per-second=N | unlimited
--concurrent-reads=N | unlimited
--concurrent-writes=N | unlimited
```
To change parameters of a running server use:
```
$ kopia server throttle set \
--address=<server-url> \
--server-control-password=<password> \
--download-bytes-per-second=N | unlimited
--upload-bytes-per-second=N | unlimited
--read-requests-per-second=N | unlimited
--write-requests-per-second=N | unlimited
--list-requests-per-second=N | unlimited
--concurrent-reads=N | unlimited
--concurrent-writes=N | unlimited
```
39 lines
815 B
Go
39 lines
815 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/kopia/kopia/repo"
|
|
)
|
|
|
|
type commandRepositoryThrottleSet struct {
|
|
cts commonThrottleSet
|
|
}
|
|
|
|
func (c *commandRepositoryThrottleSet) setup(svc appServices, parent commandParent) {
|
|
cmd := parent.Command("set", "Set throttling parameters for a repository")
|
|
c.cts.setup(cmd)
|
|
|
|
cmd.Action(svc.directRepositoryWriteAction(c.run))
|
|
}
|
|
|
|
func (c *commandRepositoryThrottleSet) run(ctx context.Context, rep repo.DirectRepositoryWriter) error {
|
|
thr := rep.Throttler()
|
|
limits := thr.Limits()
|
|
|
|
var changeCount int
|
|
|
|
if err := c.cts.apply(ctx, &limits, &changeCount); err != nil {
|
|
return err
|
|
}
|
|
|
|
if changeCount == 0 {
|
|
log(ctx).Infof("No changes made.")
|
|
return nil
|
|
}
|
|
|
|
return errors.Wrap(rep.Throttler().SetLimits(limits), "error setting limits")
|
|
}
|