Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

feat: support to modify configs without restart #682

Merged
merged 33 commits into from
Dec 22, 2020
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
fee3882
fix
levy5307 Dec 3, 2020
d3a07c0
fix
levy5307 Dec 4, 2020
8df75be
fix
levy5307 Dec 7, 2020
4a3a2c3
fix
levy5307 Dec 7, 2020
6b8f82b
fix
levy5307 Dec 7, 2020
1396ec8
fix
levy5307 Dec 7, 2020
cc93bce
fix
levy5307 Dec 7, 2020
f6e0c2f
Merge branch 'master' into config-update
levy5307 Dec 7, 2020
40c9c8b
fix
levy5307 Dec 7, 2020
84d9fda
Merge branch 'config-update' of github.com:levy5307/rdsn into config-…
levy5307 Dec 7, 2020
02bac72
fix
levy5307 Dec 7, 2020
bfaa2fd
fix
levy5307 Dec 7, 2020
24cec31
fix
levy5307 Dec 7, 2020
1c6cbb6
fix
levy5307 Dec 9, 2020
101b734
fix
levy5307 Dec 9, 2020
406c65a
fix
levy5307 Dec 10, 2020
af2319d
fix
levy5307 Dec 10, 2020
39c015a
fix
levy5307 Dec 15, 2020
e5ab823
fix
levy5307 Dec 15, 2020
d29dcbf
Merge branch 'master' into config-update
acelyc111 Dec 15, 2020
52bfa45
Merge branch 'master' into config-update
levy5307 Dec 16, 2020
f41964d
fix
levy5307 Dec 16, 2020
10b7e93
Merge branch 'master' into config-update
levy5307 Dec 16, 2020
61bb5dc
Merge branch 'master' into config-update
levy5307 Dec 16, 2020
4f3718e
Merge branch 'master' into config-update
levy5307 Dec 16, 2020
3e47c7b
Merge branch 'master' into config-update
levy5307 Dec 17, 2020
e4e3c4e
Merge branch 'master' into config-update
levy5307 Dec 17, 2020
a0af437
Merge branch 'master' into config-update
levy5307 Dec 18, 2020
41d44b4
fix
levy5307 Dec 18, 2020
c87db04
fix
levy5307 Dec 18, 2020
b308b0b
fix
levy5307 Dec 18, 2020
8840fa2
fix
levy5307 Dec 21, 2020
a5fb193
fix
levy5307 Dec 21, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix
levy5307 committed Dec 3, 2020
commit fee388265827a18b8262bfcbce6aa59bf75b2da5
2 changes: 2 additions & 0 deletions include/dsn/utility/flags.h
Original file line number Diff line number Diff line change
@@ -52,6 +52,8 @@
dassert(FLAGS_VALIDATOR_FN_##name(FLAGS_##name), "validation failed: %s", #name); \
})

#define DSN_UPDATE(name, val) flag_registry::instance().update_flag(name, val)

namespace dsn {

// An utility class that registers a flag upon initialization.
25 changes: 25 additions & 0 deletions src/utils/flags.cpp
Original file line number Diff line number Diff line change
@@ -55,6 +55,21 @@ class flag_data
{
}

bool update(const char *val)
{
switch (_type) {
case FV_INT32:
case FV_INT64:
case FV_UINT32:
case FV_UINT64:
case FV_BOOL:
case FV_DOUBLE:
case FV_STRING:
strcpy(value<char*>(), val);
break;
}
}

void set_validator(validator_fn &validator) { _validator = std::move(validator); }
const validator_fn &validator() const { return _validator; }

@@ -79,6 +94,16 @@ class flag_registry : public utils::singleton<flag_registry>
public:
void add_flag(const char *name, flag_data flag) { _flags.emplace(name, flag); }

bool update_flag(const char *name, const char *val)
{
auto it = _flags.find(name);
if (it == _flags.end()) {
return false;
}

return it->second.update(val);
}

void add_validator(const char *name, validator_fn &validator)
{
auto it = _flags.find(name);