Repository navigation
feat: support multi redis addr seperator - #179
Merged
Merged
Conversation
Contributor
Reviewer's GuideIntroduces a regex-based utility for splitting strings by multiple delimiters and refactors all Redis client constructors to leverage this new function, ensuring consistent parsing of multi-address inputs and adding unit tests for verification. Class diagram for updated Redis client constructors and new utility functionclassDiagram
class RedisStorage {
+NewRedisStorage(clusterType, addr, masterName, username, password, db)
}
class RedisStore {
+NewRedisStore(logger, cfg)
}
class RedisNotifier {
+NewRedisNotifier(logger, clusterType, addr, masterName, username, password, db, topic, role)
}
class utils {
+FirstNonEmpty(str1, str2 string) string
+SplitByMultipleDelimiters(s string, delimiters ...string) []string
}
RedisStorage ..> utils : uses
RedisStore ..> utils : uses
RedisNotifier ..> utils : uses
Class diagram for new SplitByMultipleDelimiters utility functionclassDiagram
class utils {
+SplitByMultipleDelimiters(s string, delimiters ...string) []string
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Contributor
There was a problem hiding this comment.
Hey @qiankunli - I've reviewed your changes - here's some feedback:
- Consider using strings.FieldsFunc instead of a regex for simpler and more performant splitting on multiple delimiter characters.
- The current implementation only splits on single characters (not multi‐character strings) and returns empty segments for consecutive or edge delimiters—either filter out empty entries or document this behavior.
- Rename SplitByMultipleDelimiters to something like SplitByAnyRune or SplitOnChars to clarify it handles individual characters rather than full-string delimiters.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider using strings.FieldsFunc instead of a regex for simpler and more performant splitting on multiple delimiter characters.
- The current implementation only splits on single characters (not multi‐character strings) and returns empty segments for consecutive or edge delimiters—either filter out empty entries or document this behavior.
- Rename SplitByMultipleDelimiters to something like SplitByAnyRune or SplitOnChars to clarify it handles individual characters rather than full-string delimiters.
## Individual Comments
### Comment 1
<location> `pkg/utils/str_test.go:8` </location>
<code_context>
+)
+import "github.com/stretchr/testify/assert"
+
+func TestSplitByMultipleDelimiters(t *testing.T) {
+ input := "a,b;c"
+ delimiters := []string{",", ";"}
</code_context>
<issue_to_address>
Missing edge case tests for empty input and consecutive delimiters.
Please add tests for empty input, inputs with only delimiters, consecutive delimiters, and delimiters at the start or end to ensure comprehensive coverage.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Add support for parsing multiple Redis address separators by introducing a generic splitting utility and applying it to all Redis clients
New Features:
Enhancements:
Tests: