From 0d940e3aa8e8911a4a8b7b8cd579dc8f6f248a48 Mon Sep 17 00:00:00 2001 From: Yury-Fridlyand Date: Thu, 9 Jan 2025 11:19:28 -0800 Subject: [PATCH] refactor Signed-off-by: Yury-Fridlyand --- go/api/options/zrange_options.go | 37 ++++++++++++++------------- go/integTest/glide_test_suite_test.go | 2 +- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/go/api/options/zrange_options.go b/go/api/options/zrange_options.go index c04fa7f8d6..002dc38e24 100644 --- a/go/api/options/zrange_options.go +++ b/go/api/options/zrange_options.go @@ -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 ( @@ -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 @@ -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} } @@ -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} } diff --git a/go/integTest/glide_test_suite_test.go b/go/integTest/glide_test_suite_test.go index 46752041ce..fc6a5c8ff7 100644 --- a/go/integTest/glide_test_suite_test.go +++ b/go/integTest/glide_test_suite_test.go @@ -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)) }