empiredan commented on code in PR #1198:
URL: 
https://github.com/apache/incubator-pegasus/pull/1198#discussion_r1034530709


##########
src/http/http_server.cpp:
##########
@@ -65,21 +81,38 @@ DSN_DEFINE_bool("http", enable_http_server, true, "whether 
to enable the embedde
     http_call_registry::instance().remove(full_path);
 }
 
-void http_service::register_handler(std::string path, http_callback cb, 
std::string help)
+void http_service::register_handler(std::string sub_path, http_callback cb, 
std::string help)
 {
+    CHECK(!sub_path.empty(), "");

Review Comment:
   ```suggestion
       CHECK(!utils::is_empty(sub_path), "");
   ```



##########
src/http/http_server.cpp:
##########
@@ -65,21 +81,38 @@ DSN_DEFINE_bool("http", enable_http_server, true, "whether 
to enable the embedde
     http_call_registry::instance().remove(full_path);
 }
 
-void http_service::register_handler(std::string path, http_callback cb, 
std::string help)
+void http_service::register_handler(std::string sub_path, http_callback cb, 
std::string help)
 {
+    CHECK(!sub_path.empty(), "");
     if (!FLAGS_enable_http_server) {
         return;
     }
     auto call = make_unique<http_call>();
-    call->path = this->path();
-    if (!path.empty()) {
-        call->path += "/" + std::move(path);
+    if (this->path().empty()) {
+        call->path = std::move(sub_path);
+    } else {
+        call->path = this->path() + "/" + std::move(sub_path);
     }
     call->callback = std::move(cb);
     call->help = std::move(help);

Review Comment:
   ```suggestion
       call->help = help;
   ```



##########
src/http/http_server.cpp:
##########
@@ -65,21 +81,38 @@ DSN_DEFINE_bool("http", enable_http_server, true, "whether 
to enable the embedde
     http_call_registry::instance().remove(full_path);
 }
 
-void http_service::register_handler(std::string path, http_callback cb, 
std::string help)
+void http_service::register_handler(std::string sub_path, http_callback cb, 
std::string help)

Review Comment:
   ```suggestion
   void http_service::register_handler(const char *sub_path, http_callback cb, 
const char *help)
   ```



##########
src/http/http_server.cpp:
##########
@@ -65,21 +81,38 @@ DSN_DEFINE_bool("http", enable_http_server, true, "whether 
to enable the embedde
     http_call_registry::instance().remove(full_path);
 }
 
-void http_service::register_handler(std::string path, http_callback cb, 
std::string help)
+void http_service::register_handler(std::string sub_path, http_callback cb, 
std::string help)
 {
+    CHECK(!sub_path.empty(), "");
     if (!FLAGS_enable_http_server) {
         return;
     }
     auto call = make_unique<http_call>();
-    call->path = this->path();
-    if (!path.empty()) {
-        call->path += "/" + std::move(path);
+    if (this->path().empty()) {
+        call->path = std::move(sub_path);
+    } else {
+        call->path = this->path() + "/" + std::move(sub_path);
     }

Review Comment:
   ```suggestion
       call->path = this->path();
       if (!call->path.empty()) {
           call->path += '/';
       }
       call->path += sub_path;
   ```



##########
src/replica/replica_stub.h:
##########
@@ -230,6 +230,8 @@ class replica_stub : public serverlet<replica_stub>, public 
ref_counter
     // query last checkpoint info for follower in duplication process
     void on_query_last_checkpoint(query_last_checkpoint_info_rpc rpc);
 
+    virtual void update_config(const std::string &name);

Review Comment:
   Is this necessary to be declared as `virtual` ?



##########
src/http/http_server.cpp:
##########
@@ -65,21 +81,38 @@ DSN_DEFINE_bool("http", enable_http_server, true, "whether 
to enable the embedde
     http_call_registry::instance().remove(full_path);
 }
 
-void http_service::register_handler(std::string path, http_callback cb, 
std::string help)
+void http_service::register_handler(std::string sub_path, http_callback cb, 
std::string help)
 {
+    CHECK(!sub_path.empty(), "");
     if (!FLAGS_enable_http_server) {
         return;
     }
     auto call = make_unique<http_call>();
-    call->path = this->path();
-    if (!path.empty()) {
-        call->path += "/" + std::move(path);
+    if (this->path().empty()) {
+        call->path = std::move(sub_path);
+    } else {
+        call->path = this->path() + "/" + std::move(sub_path);
     }
     call->callback = std::move(cb);
     call->help = std::move(help);
     http_call_registry::instance().add(std::move(call));
 }
 
+void http_server_base::update_config_handler(const http_request &req, 
http_response &resp)
+{
+    auto res = dsn::update_config(req);
+    if (res.is_ok()) {
+        CHECK_EQ(1, req.query_args.size());
+        update_config(req.query_args.begin()->first);
+    }

Review Comment:
   Even the returned `res` is not ok, the status code of http response is still 
http_status_code::ok, rather than `http_status_code::bad_request`, right ? The 
error message will be put in response body, as `"update_status"` given by 
`res.description()`  ?



##########
src/runtime/task/task.h:
##########
@@ -359,15 +359,18 @@ class timer_task : public task
     void exec() override;
     void enqueue() override;
 
+    void update_interval(int interval_ms);
+
 protected:
     void clear_non_trivial_on_task_end() override { _cb = nullptr; }
 
 private:
-    // ATTENTION: if _interval_milliseconds <= 0, then timer task will just be 
executed once;
-    // otherwise, timer task will be executed periodically(period = 
_interval_milliseconds)
-    int _interval_milliseconds;
+    // ATTENTION: if _interval_ms == 0, then timer task will just be executed 
once;
+    // otherwise, timer task will be executed periodically(period = 
_interval_ms)
+    int _interval_ms;

Review Comment:
   Declared as `uint32_t` ?



##########
src/http/http_server.h:
##########
@@ -100,7 +100,31 @@ class http_service
 
     virtual std::string path() const = 0;
 
-    void register_handler(std::string path, http_callback cb, std::string 
help);
+    void register_handler(std::string sub_path, http_callback cb, std::string 
help);

Review Comment:
   ```suggestion
       void register_handler(const char *sub_path, http_callback cb, const char 
*help);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to