mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* Bump github.com/alicebob/miniredis/v2 from 2.21.0 to 2.34.0 Bumps [github.com/alicebob/miniredis/v2](https://github.com/alicebob/miniredis) from 2.21.0 to 2.34.0. - [Release notes](https://github.com/alicebob/miniredis/releases) - [Changelog](https://github.com/alicebob/miniredis/blob/master/CHANGELOG.md) - [Commits](https://github.com/alicebob/miniredis/compare/v2.21.0...v2.34.0) --- updated-dependencies: - dependency-name: github.com/alicebob/miniredis/v2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Update serverless gomod --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: tempo-gh-bot[bot] <[email protected]>
61 lines
1.2 KiB
Go
61 lines
1.2 KiB
Go
package miniredis
|
|
|
|
import (
|
|
"errors"
|
|
"math"
|
|
"strconv"
|
|
"time"
|
|
|
|
"github.com/alicebob/miniredis/v2/server"
|
|
)
|
|
|
|
// optInt parses an int option in a command.
|
|
// Writes "invalid integer" error to c if it's not a valid integer. Returns
|
|
// whether or not things were okay.
|
|
func optInt(c *server.Peer, src string, dest *int) bool {
|
|
return optIntErr(c, src, dest, msgInvalidInt)
|
|
}
|
|
|
|
func optIntErr(c *server.Peer, src string, dest *int, errMsg string) bool {
|
|
n, err := strconv.Atoi(src)
|
|
if err != nil {
|
|
setDirty(c)
|
|
c.WriteError(errMsg)
|
|
return false
|
|
}
|
|
*dest = n
|
|
return true
|
|
}
|
|
|
|
// optIntSimple sets dest or returns an error
|
|
func optIntSimple(src string, dest *int) error {
|
|
n, err := strconv.Atoi(src)
|
|
if err != nil {
|
|
return errors.New(msgInvalidInt)
|
|
}
|
|
*dest = n
|
|
return nil
|
|
}
|
|
|
|
func optDuration(c *server.Peer, src string, dest *time.Duration) bool {
|
|
n, err := strconv.ParseFloat(src, 64)
|
|
if err != nil {
|
|
setDirty(c)
|
|
c.WriteError(msgInvalidTimeout)
|
|
return false
|
|
}
|
|
if n < 0 {
|
|
setDirty(c)
|
|
c.WriteError(msgTimeoutNegative)
|
|
return false
|
|
}
|
|
if math.IsInf(n, 0) {
|
|
setDirty(c)
|
|
c.WriteError(msgTimeoutIsOutOfRange)
|
|
return false
|
|
}
|
|
|
|
*dest = time.Duration(n*1_000_000) * time.Microsecond
|
|
return true
|
|
}
|