Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
empiredan committed Jan 10, 2025
1 parent 44f885c commit 4645a73
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
35 changes: 10 additions & 25 deletions src/client/replication_ddl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,12 @@ dsn::error_code replication_ddl_client::create_app(const std::string &app_name,
bool success_if_exist)
{
if (partition_count < 1) {
std::cout << "create app " << app_name << " failed: partition_count should >= 1"
<< std::endl;
fmt::println(stderr, "create app {} failed: partition_count should >= 1", app_name);
return ERR_INVALID_PARAMETERS;
}

if (replica_count < 1) {
std::cout << "create app " << app_name << " failed: replica_count should >= 1" << std::endl;
fmt::println(stderr, "create app {} failed: replica_count should >= 1", app_name);
return ERR_INVALID_PARAMETERS;
}

Expand All @@ -215,16 +214,13 @@ dsn::error_code replication_ddl_client::create_app(const std::string &app_name,
req->options.is_stateful = !is_stateless;

dsn::replication::configuration_create_app_response resp;
const auto &req_result = request_meta_and_wait_response(RPC_CM_CREATE_APP, req, resp);

if (!req_result) {
fmt::println("create app {} failed: [create] call server error: {}", app_name, req_result);
return req_result.code();
}
RETURN_EC_NOT_OK_MSG(request_meta_and_wait_response(RPC_CM_CREATE_APP, req, resp),
"create app {} failed: [create] call server error",
app_name);

if (resp.err != dsn::ERR_OK) {
fmt::println(
"create app {} failed: [create] received server error: {}", app_name, resp.err);
stderr, "{}: create app {} failed: [create] received server error", resp.err, app_name);
return resp.err;
}

Expand All @@ -248,11 +244,7 @@ dsn::error_code replication_ddl_client::drop_app(const std::string &app_name, in
req->options.__set_reserve_seconds(reserve_seconds);

dsn::replication::configuration_drop_app_response resp;
const auto &req_result = request_meta_and_wait_response(RPC_CM_DROP_APP, req, resp);

if (!req_result) {
return req_result.code();
}
RETURN_EC_NOT_OK(request_meta_and_wait_response(RPC_CM_DROP_APP, req, resp));

if (resp.err != dsn::ERR_OK) {
return resp.err;
Expand All @@ -270,11 +262,7 @@ dsn::error_code replication_ddl_client::recall_app(int32_t app_id, const std::st
req->new_app_name = new_app_name;

dsn::replication::configuration_recall_app_response resp;
const auto &req_result = request_meta_and_wait_response(RPC_CM_RECALL_APP, req, resp);

if (!req_result) {
return req_result.code();
}
RETURN_EC_NOT_OK(request_meta_and_wait_response(RPC_CM_RECALL_APP, req, resp));

if (resp.err != dsn::ERR_OK) {
return resp.err;
Expand Down Expand Up @@ -1385,11 +1373,8 @@ dsn::error_code replication_ddl_client::get_app_envs(const std::string &app_name
// Just match the table with the provided name exactly since we want to get the envs from
// a specific table.
std::vector<::dsn::app_info> apps;
const auto &result = list_apps(
dsn::app_status::AS_AVAILABLE, app_name, utils::pattern_match_type::PMT_MATCH_EXACT, apps);
if (!result) {
return result.code();
}
RETURN_EC_NOT_OK(list_apps(
dsn::app_status::AS_AVAILABLE, app_name, utils::pattern_match_type::PMT_MATCH_EXACT, apps));

for (const auto &app : apps) {
// Once the meta server does not support `app_name` and `match_type` (still the old
Expand Down
14 changes: 11 additions & 3 deletions src/utils/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,19 @@ USER_DEFINED_STRUCTURE_FORMATTER(::dsn::error_s);
} \
} while (false)

#define RETURN_EC_NOT_OK(s) \
do { \
const ::dsn::error_s &_s = (s); \
if (dsn_unlikely(!_s)) { \
return _s.code(); \
} \
} while (false)

#define RETURN_ES_NOT_OK_MSG(s, ...) \
do { \
const ::dsn::error_s &_s = (s); \
if (dsn_unlikely(!_s)) { \
fmt::print(stderr, "{}: {}\n", _s.description(), fmt::format(__VA_ARGS__)); \
fmt::println(stderr, "{}: {}", _s, fmt::format(__VA_ARGS__)); \
return _s; \
} \
} while (false)
Expand All @@ -259,7 +267,7 @@ USER_DEFINED_STRUCTURE_FORMATTER(::dsn::error_s);
do { \
const ::dsn::error_s &_s = (s); \
if (dsn_unlikely(!_s)) { \
fmt::print(stderr, "{}: {}\n", _s.description(), fmt::format(__VA_ARGS__)); \
fmt::println(stderr, "{}: {}", _s, fmt::format(__VA_ARGS__)); \
return _s.code(); \
} \
} while (false)
Expand All @@ -268,7 +276,7 @@ USER_DEFINED_STRUCTURE_FORMATTER(::dsn::error_s);
do { \
::dsn::error_s _s = (s); \
if (dsn_unlikely(!_s)) { \
fmt::print(stderr, "{}: {}\n", _s.description(), fmt::format(__VA_ARGS__)); \
fmt::println(stderr, "{}: {}", _s, fmt::format(__VA_ARGS__)); \
return dsn::error_with<T>(std::move(_s)); \
} \
} while (false)
Expand Down

0 comments on commit 4645a73

Please sign in to comment.