Skip to content

Commit

Permalink
Support uint32 reloadable flags (#2483)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenBright authored Dec 27, 2023
1 parent 4357cee commit 023fa14
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/brpc/reloadable_flags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ bool PassValidate(const char*, bool) {
bool PassValidate(const char*, int32_t) {
return true;
}
bool PassValidate(const char*, uint32_t) {
return true;
}
bool PassValidate(const char*, int64_t) {
return true;
}
Expand All @@ -42,9 +45,15 @@ bool PassValidate(const char*, double) {
bool PositiveInteger(const char*, int32_t val) {
return val > 0;
}
bool PositiveInteger(const char*, uint32_t val) {
return val > 0;
}
bool PositiveInteger(const char*, int64_t val) {
return val > 0;
}
bool PositiveInteger(const char*, uint64_t val) {
return val > 0;
}

bool NonNegativeInteger(const char*, int32_t val) {
return val >= 0;
Expand Down
5 changes: 5 additions & 0 deletions src/brpc/reloadable_flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,15 @@ namespace brpc {

extern bool PassValidate(const char*, bool);
extern bool PassValidate(const char*, int32_t);
extern bool PassValidate(const char*, uint32_t);
extern bool PassValidate(const char*, int64_t);
extern bool PassValidate(const char*, uint64_t);
extern bool PassValidate(const char*, double);

extern bool PositiveInteger(const char*, int32_t);
extern bool PositiveInteger(const char*, uint32_t);
extern bool PositiveInteger(const char*, int64_t);
extern bool PositiveInteger(const char*, uint64_t);

extern bool NonNegativeInteger(const char*, int32_t);
extern bool NonNegativeInteger(const char*, int64_t);
Expand All @@ -59,6 +62,8 @@ extern bool RegisterFlagValidatorOrDie(const bool* flag,
bool (*validate_fn)(const char*, bool));
extern bool RegisterFlagValidatorOrDie(const int32_t* flag,
bool (*validate_fn)(const char*, int32_t));
extern bool RegisterFlagValidatorOrDie(const uint32_t* flag,
bool (*validate_fn)(const char*, uint32_t));
extern bool RegisterFlagValidatorOrDie(const int64_t* flag,
bool (*validate_fn)(const char*, int64_t));
extern bool RegisterFlagValidatorOrDie(const uint64_t* flag,
Expand Down

0 comments on commit 023fa14

Please sign in to comment.