yugabyte / yugabyte-db

YugabyteDB - the cloud native distributed SQL database for mission-critical applications.
https://www.yugabyte.com
Other
8.97k stars 1.07k forks source link

[DocDB] Reduce boilerplate for gflag validators #24368

Open es1024 opened 3 weeks ago

es1024 commented 3 weeks ago

Jira Link: DB-13280

Description

Code for validating gflag values is fairly verbose, e.g.

namespace {

bool RpcMaxMessageSizeValidator(const char* flag_name, uint64_t value) {
  // This validation depends on the value of: protobuf_message_total_bytes_limit.
  DELAY_FLAG_VALIDATION_ON_STARTUP(flag_name);

  if (value >= FLAGS_protobuf_message_total_bytes_limit) {
    LOG_FLAG_VALIDATION_ERROR(flag_name, value)
        << "Must be less than protobuf_message_total_bytes_limit "
        << FLAGS_protobuf_message_total_bytes_limit;
    return false;
  }

  return true;
}

} // namespace

DEFINE_validator(rpc_max_message_size, &RpcMaxMessageSizeValidator);

It's also fairly repetitive (e.g. flag A < flag B, flag > 0 checks are done in multiple places) and could be reduced.

Issue Type

kind/enhancement

Warning: Please confirm that this issue does not contain any sensitive information

rthallamko3 commented 2 weeks ago

Lets backport to 2024.2 as we plan to backport the CDC fix that needs this.