Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
Signed-off-by: Yury-Fridlyand <[email protected]>
  • Loading branch information
Yury-Fridlyand committed Jan 9, 2025
1 parent 780967b commit 0d940e3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
37 changes: 19 additions & 18 deletions go/api/options/zrange_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,22 @@ type RangeByIndex struct {

// Queries a range of elements from a sorted set by theirs score.
type RangeByScore struct {
start, end boundary
start, end scoreBoundary
reverse bool
Limit *Limit
}

// Queries a range of elements from a sorted set by theirs lexicographical order.
type RangeByLex struct {
start, end boundary
start, end lexBoundary
reverse bool
Limit *Limit
}

type (
InfBoundary string
boundary string
InfBoundary string
scoreBoundary string
lexBoundary string
)

const (
Expand All @@ -47,34 +48,34 @@ const (
)

// Create a new inclusive score boundary.
func NewInclusiveScoreBoundary(bound float64) boundary {
return boundary(utils.FloatToString(bound))
func NewInclusiveScoreBoundary(bound float64) scoreBoundary {
return scoreBoundary(utils.FloatToString(bound))
}

// Create a new score boundary.
func NewScoreBoundary(bound float64, isInclusive bool) boundary {
func NewScoreBoundary(bound float64, isInclusive bool) scoreBoundary {
if !isInclusive {
return boundary("(" + utils.FloatToString(bound))
return scoreBoundary("(" + utils.FloatToString(bound))
}
return boundary(utils.FloatToString(bound))
return scoreBoundary(utils.FloatToString(bound))
}

// Create a new score boundary defined by an infinity.
func NewInfiniteScoreBoundary(bound InfBoundary) boundary {
return boundary(string(bound) + "inf")
func NewInfiniteScoreBoundary(bound InfBoundary) scoreBoundary {
return scoreBoundary(string(bound) + "inf")
}

// Create a new lex boundary.
func NewLexBoundary(bound string, isInclusive bool) boundary {
func NewLexBoundary(bound string, isInclusive bool) lexBoundary {
if !isInclusive {
return boundary("(" + bound)
return lexBoundary("(" + bound)
}
return boundary("[" + bound)
return lexBoundary("[" + bound)
}

// Create a new lex boundary defined by an infinity.
func NewInfiniteLexBoundary(bound InfBoundary) boundary {
return boundary(string(bound))
func NewInfiniteLexBoundary(bound InfBoundary) lexBoundary {
return lexBoundary(string(bound))
}

// TODO re-use limit from `SORT` https://github.com/valkey-io/valkey-glide/pull/2888
Expand Down Expand Up @@ -123,7 +124,7 @@ func (rbi *RangeByIndex) ToArgs() []string {
//
// start - The start score of the range.
// end - The end score of the range.
func NewRangeByScoreQuery(start boundary, end boundary) *RangeByScore {
func NewRangeByScoreQuery(start scoreBoundary, end scoreBoundary) *RangeByScore {
return &RangeByScore{start, end, false, nil}
}

Expand Down Expand Up @@ -157,7 +158,7 @@ func (rbs *RangeByScore) ToArgs() []string {
//
// start - The start lex of the range.
// end - The end lex of the range.
func NewRangeByLexQuery(start boundary, end boundary) *RangeByLex {
func NewRangeByLexQuery(start lexBoundary, end lexBoundary) *RangeByLex {
return &RangeByLex{start, end, false, nil}
}

Expand Down
2 changes: 1 addition & 1 deletion go/integTest/glide_test_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func extractAddresses(suite *GlideTestSuite, output string) []api.NodeAddress {
func runClusterManager(suite *GlideTestSuite, args []string, ignoreExitCode bool) string {
pythonArgs := append([]string{"../../utils/cluster_manager.py"}, args...)
output, err := exec.Command("python3", pythonArgs...).CombinedOutput()
if len(output) > 0 {
if len(output) > 0 && !ignoreExitCode {
suite.T().Logf("cluster_manager.py output:\n====\n%s\n====\n", string(output))
}

Expand Down

0 comments on commit 0d940e3

Please sign in to comment.