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

meta_service & server_state: support set/del/clear envs for app #13

Merged
merged 4 commits into from
Apr 17, 2018

Conversation

LoveHeat
Copy link
Contributor

No description provided.

3:optional app_env_set_request set_req;
4:optional app_env_del_request del_req;
5:optional app_env_clear_request clear_req;
}
Copy link
Member

Choose a reason for hiding this comment

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

+struct configuration_update_app_env_request
+{

  • 1:string app_name;
  • 2:app_env_operation op = app_env_operation.APP_ENV_OP_INVALID;
  • 3:optional list keys; // used for set & del
  • 4:optional list values; // used for set
  • 5:optional string clear_prefix; // used for clear, empty means clear all
    +}

@@ -129,6 +129,12 @@ class serverlet : public virtual clientlet
void (T::*handler)(TRpcHolder),
dsn::gpid gpid = {});

template <typename TRpcHolder>
Copy link
Member

Choose a reason for hiding this comment

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

去掉这个

Copy link
Contributor

@neverchanje neverchanje Apr 16, 2018

Choose a reason for hiding this comment

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

master 分支的 rdsn 已经为你提供了这个函数。https://github.com/XiaoMi/rdsn/blob/master/include/dsn/cpp/serverlet.h

@@ -156,6 +156,12 @@ class replication_ddl_client : public clientlet
int32_t backup_history_count_to_keep = 0,
const std::string &start_time = std::string());

dsn::error_code
set_app_env(const std::string &app_name, const std::string &key, const std::string &vlaue);
dsn::error_code del_app_envs(const std::string &app_name, const std::vector<std::string> &keys);
Copy link
Member

Choose a reason for hiding this comment

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

传std::set更合适吧?

@@ -156,6 +156,12 @@ class replication_ddl_client : public clientlet
int32_t backup_history_count_to_keep = 0,
const std::string &start_time = std::string());

dsn::error_code
set_app_env(const std::string &app_name, const std::string &key, const std::string &vlaue);
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: value 拼错

void meta_service::update_app_env(const app_env_rpc &env_rpc)
{
configuration_update_app_env_response response;
RPC_CHECK_STATUS(env_rpc.dsn_request(), response);
Copy link
Contributor

@neverchanje neverchanje Apr 16, 2018

Choose a reason for hiding this comment

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

env_rpc.response(),不用构造 response

@neverchanje
Copy link
Contributor

我建议 app_env 相关的代码统一写到一个单独的文件:meta_app_env_service.h/.cpp,方便代码阅读。

@neverchanje
Copy link
Contributor

Copy link
Member

@qinzuoyan qinzuoyan left a comment

Choose a reason for hiding this comment

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

还要改

nullptr,
std::bind(&server_state::clear_app_envs, _state.get(), env_rpc));
break;
default: // app_env_operation::type::APP_ENV_OP_INVALID
Copy link
Member

Choose a reason for hiding this comment

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

如果invalid,返回的错误码是什么?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

zauto_read_lock l(_lock);
std::shared_ptr<app_state> app = get_app(app_name);
if (app == nullptr) {
dwarn("del_app_env failed with invalid app_name(%s)", app_name.c_str());
Copy link
Member

Choose a reason for hiding this comment

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

response.err是什么?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

zauto_read_lock l(_lock);
std::shared_ptr<app_state> app = get_app(app_name);
if (app == nullptr) {
dwarn("del_app_env failed with invalid app_name(%s)", app_name.c_str());
Copy link
Member

Choose a reason for hiding this comment

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

response.err是什么?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

zauto_read_lock l(_lock);
std::shared_ptr<app_state> app = get_app(app_name);
if (app == nullptr) {
dwarn("set_app_env failed with invalid app_name(%s)", app_name.c_str());
Copy link
Member

Choose a reason for hiding this comment

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

response.err是什么?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fix

std::cout << "set app env succeed" << std::endl;
if (!response.hint_message.empty()) {
std::cout << "=============================" << std::endl;
std::cout << response.hint_message << std::endl;
Copy link
Member

Choose a reason for hiding this comment

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

hint_message有没有可能为空?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

操作成功时候为空

2:app_env_operation op = app_env_operation.APP_ENV_OP_INVALID;
3:optional list<string> keys; // used for set and del
4:optional list<string> values; // only used for set
5:optional bool clear_all; // only used for clear;
Copy link
Member

Choose a reason for hiding this comment

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

最好去掉clear_all

Copy link
Member

@qinzuoyan qinzuoyan left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants