Files
kopia/cli/command_server_throttle_get.go
Jarek Kowalski 8515d050e5 test(infra): improved support for in-process testing (#2169)
* feat(infra): improved support for in-process testing

* support for killing of a running server using simulated Ctrl-C
* support for overriding os.Stdin
* migrated many tests from the exe runner to in-process runner

* added required indirection when defining Envar() so we can later override it in tests

* refactored CLI runners by moving environment overrides to CLITestEnv
2022-07-09 18:22:50 -07:00

34 lines
795 B
Go

package cli
import (
"context"
"github.com/pkg/errors"
"github.com/kopia/kopia/internal/apiclient"
"github.com/kopia/kopia/repo/blob/throttling"
)
type commandServerThrottleGet struct {
sf serverClientFlags
ctg commonThrottleGet
}
func (c *commandServerThrottleGet) setup(svc appServices, parent commandParent) {
cmd := parent.Command("get", "Get throttling parameters for a running server")
c.sf.setup(svc, cmd)
c.ctg.setup(svc, cmd)
cmd.Action(svc.serverAction(&c.sf, c.run))
}
func (c *commandServerThrottleGet) run(ctx context.Context, cli *apiclient.KopiaAPIClient) error {
var limits throttling.Limits
if err := cli.Get(ctx, "control/throttle", nil, &limits); err != nil {
return errors.Wrap(err, "unable to get current throttle")
}
return c.ctg.output(&limits)
}