(ctx context.Context, desc string, bps bool, val *float64, str string, changeCount *int)
| 60 | } |
| 61 | |
| 62 | func (c *commonThrottleSet) setThrottleFloat64(ctx context.Context, desc string, bps bool, val *float64, str string, changeCount *int) error { |
| 63 | if str == "" { |
| 64 | // not changed |
| 65 | return nil |
| 66 | } |
| 67 | |
| 68 | if str == "unlimited" || str == "-" { |
| 69 | *changeCount++ |
| 70 | |
| 71 | log(ctx).Infof("Setting %v to a unlimited.", desc) |
| 72 | |
| 73 | *val = 0 |
| 74 | |
| 75 | return nil |
| 76 | } |
| 77 | |
| 78 | v, err := strconv.ParseFloat(str, 64) |
| 79 | if err != nil { |
| 80 | return errors.Wrapf(err, "can't parse the %v %q", desc, str) |
| 81 | } |
| 82 | |
| 83 | *changeCount++ |
| 84 | |
| 85 | if bps { |
| 86 | log(ctx).Infof("Setting %v to %v.", desc, units.BytesPerSecondsString(v)) |
| 87 | } else { |
| 88 | log(ctx).Infof("Setting %v to %v.", desc, v) |
| 89 | } |
| 90 | |
| 91 | *val = v |
| 92 | |
| 93 | return nil |
| 94 | } |
| 95 | |
| 96 | func (c *commonThrottleSet) setThrottleInt(ctx context.Context, desc string, val *int, str string, changeCount *int) error { |
| 97 | if str == "" { |
no test coverage detected