Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(config): support retrieving configuration fields using glob patterns #2592

Merged
merged 6 commits into from
Oct 12, 2024

Conversation

sryanyuan
Copy link
Contributor

It can be difficult to remember the full configuration field, so providing a keyword to retrieve the configuration value, as is done in Redis, can be more convenient.


// NOLINTBEGIN
/* Glob-style pattern matching. */
int stringmatchlen(const char *pattern, int patternLen, const char *string, int stringLen, int nocase) {
Copy link
Member

@PragmaTwice PragmaTwice Oct 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we already have one called StringMatch in https://github.com/apache/kvrocks/blob/unstable/src/common/string_util.cc .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i'll use this one

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -867,7 +868,7 @@ Status Config::Load(const CLIOptions &opts) {
void Config::Get(const std::string &key, std::vector<std::string> *values) const {
values->clear();
for (const auto &iter : fields_) {
if (key == "*" || util::ToLower(key) == iter.first) {
if (util::StringMatchLen(key.c_str(), key.size(), iter.first.c_str(), iter.first.size(), 1)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (util::StringMatchLen(key.c_str(), key.size(), iter.first.c_str(), iter.first.size(), 1)) {
if (util::StringMatch(key, iter.first, 1)) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link

sonarcloud bot commented Oct 12, 2024

Copy link
Member

@PragmaTwice PragmaTwice left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@PragmaTwice PragmaTwice merged commit 4fb0489 into apache:unstable Oct 12, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants