Skip to content

Restrict BRPC_VALIDATE_GFLAG to global scope and namespace scope only#2625

Merged
wwbmmm merged 1 commit into
apache:masterfrom
chenBright:opt_flag_marco
May 6, 2024
Merged

Restrict BRPC_VALIDATE_GFLAG to global scope and namespace scope only#2625
wwbmmm merged 1 commit into
apache:masterfrom
chenBright:opt_flag_marco

Conversation

@chenBright

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number:

Problem Summary:

What is changed and the side effects?

Changed:

限制BRPC_VALIDATE_GFLAG只能在全局作用域或者namespace中使用,避免注册失败导致运行中的进程退出了。

Side effects:

  • Performance effects(性能影响):

  • Breaking backward compatibility(向后兼容性):


Check List:

  • Please make sure your changes are compilable(请确保你的更改可以通过编译).
  • When providing us with a new feature, it is best to add related tests(如果你向我们增加一个新的功能, 请添加相关测试).
  • Please follow Contributor Covenant Code of Conduct.(请遵循贡献者准则).

@wwbmmm wwbmmm merged commit 4c5fad0 into apache:master May 6, 2024
@chenBright chenBright deleted the opt_flag_marco branch May 7, 2024 02:15
@yanglimingcn

Copy link
Copy Markdown
Contributor

有时候希望gflags的validator在第一次加载的时候不执行validator,因为validator里面的一些内容需要在程序起来后才能有效。
这个PR对这种情况如何处理呢?

@chenBright

Copy link
Copy Markdown
Contributor Author

// Register an always-true valiator to a gflag so that the gflag is treated as
// reloadable by brpc. If a validator exists, abort the program.
// You should call this macro within global scope. for example:

从注释能看出,BRPC_VALIDATE_GFLAG的设计的初衷就是期望只在全局作用域调的。

如果需要在程序起来后起作用的话,自己调GFLAGS_NS::RegisterFlagValidator来注册回调函数就行了吧。

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.

3 participants