Browse Source

Update drogon to 1.1.0 (#6107)

An Tao 4 years ago
parent
commit
5f698665c0

+ 2 - 2
frameworks/C++/drogon/drogon-core.dockerfile

@@ -45,7 +45,7 @@ RUN git clone https://github.com/an-tao/drogon
 
 
 WORKDIR $DROGON_ROOT
 WORKDIR $DROGON_ROOT
 
 
-RUN git checkout 668533fbbd20eb9c493841b0e1067097aadf0342
+RUN git checkout fb17efe765d162be01680b05a3a387c7a182a4c5 
 RUN git submodule update --init
 RUN git submodule update --init
 RUN mkdir build
 RUN mkdir build
 
 
@@ -59,7 +59,7 @@ WORKDIR $IROOT
 RUN git clone https://github.com/microsoft/mimalloc
 RUN git clone https://github.com/microsoft/mimalloc
 
 
 WORKDIR $MIMALLOC_ROOT
 WORKDIR $MIMALLOC_ROOT
-RUN git checkout v1.6.2 -b v1.6.2
+RUN git checkout v1.6.7 -b v1.6.7
 RUN mkdir -p out/release
 RUN mkdir -p out/release
 WORKDIR $MIMALLOC_ROOT/out/release
 WORKDIR $MIMALLOC_ROOT/out/release
 RUN cmake ../..
 RUN cmake ../..

+ 2 - 2
frameworks/C++/drogon/drogon.dockerfile

@@ -45,7 +45,7 @@ RUN git clone https://github.com/an-tao/drogon
 
 
 WORKDIR $DROGON_ROOT
 WORKDIR $DROGON_ROOT
 
 
-RUN git checkout 668533fbbd20eb9c493841b0e1067097aadf0342
+RUN git checkout fb17efe765d162be01680b05a3a387c7a182a4c5 
 RUN git submodule update --init
 RUN git submodule update --init
 RUN mkdir build
 RUN mkdir build
 
 
@@ -59,7 +59,7 @@ WORKDIR $IROOT
 RUN git clone https://github.com/microsoft/mimalloc
 RUN git clone https://github.com/microsoft/mimalloc
 
 
 WORKDIR $MIMALLOC_ROOT
 WORKDIR $MIMALLOC_ROOT
-RUN git checkout v1.6.2 -b v1.6.2
+RUN git checkout v1.6.7 -b v1.6.7
 RUN mkdir -p out/release
 RUN mkdir -p out/release
 WORKDIR $MIMALLOC_ROOT/out/release
 WORKDIR $MIMALLOC_ROOT/out/release
 RUN cmake ../..
 RUN cmake ../..

+ 3 - 3
frameworks/C++/drogon/drogon_benchmark/controllers/DbCtrlRaw.cc

@@ -1,10 +1,9 @@
 #include "DbCtrlRaw.h"
 #include "DbCtrlRaw.h"
-#include "models/World.h"
+#include "World_raw.h"
 #include <drogon/utils/Utilities.h>
 #include <drogon/utils/Utilities.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <thread>
 #include <thread>
 #include <time.h>
 #include <time.h>
-using namespace drogon_model::hello_world;
 
 
 void DbCtrlRaw::asyncHandleHttpRequest(
 void DbCtrlRaw::asyncHandleHttpRequest(
     const HttpRequestPtr &req,
     const HttpRequestPtr &req,
@@ -34,7 +33,8 @@ void DbCtrlRaw::asyncHandleHttpRequest(
                 Json::Value json{};
                 Json::Value json{};
                 json["code"] = 0;
                 json["code"] = 0;
                 json["message"] = "Internal error";
                 json["message"] = "Internal error";
-                (*callbackPtr)(HttpResponse::newHttpJsonResponse(std::move(json)));
+                (*callbackPtr)(
+                    HttpResponse::newHttpJsonResponse(std::move(json)));
             }
             }
         } >>
         } >>
         [callbackPtr](const DrogonDbException &err) {
         [callbackPtr](const DrogonDbException &err) {

+ 5 - 5
frameworks/C++/drogon/drogon_benchmark/controllers/QueriesCtrlRaw.cc

@@ -1,9 +1,7 @@
 #include "QueriesCtrlRaw.h"
 #include "QueriesCtrlRaw.h"
-#include "models/World.h"
+#include "World_raw.h"
 #include <stdlib.h>
 #include <stdlib.h>
 
 
-using namespace drogon_model::hello_world;
-
 using namespace drogon::orm;
 using namespace drogon::orm;
 void QueriesCtrlRaw::asyncHandleHttpRequest(
 void QueriesCtrlRaw::asyncHandleHttpRequest(
     const HttpRequestPtr &req,
     const HttpRequestPtr &req,
@@ -46,7 +44,8 @@ void QueriesCtrlRaw::asyncHandleHttpRequest(
                     (*counter)--;
                     (*counter)--;
                     if ((*counter) == 0)
                     if ((*counter) == 0)
                     {
                     {
-                        (*callbackPtr)(HttpResponse::newHttpJsonResponse(std::move(*json)));
+                        (*callbackPtr)(HttpResponse::newHttpJsonResponse(
+                            std::move(*json)));
                     }
                     }
                 }
                 }
                 else
                 else
@@ -55,7 +54,8 @@ void QueriesCtrlRaw::asyncHandleHttpRequest(
                     Json::Value json{};
                     Json::Value json{};
                     json["code"] = 0;
                     json["code"] = 0;
                     json["message"] = "Internal error";
                     json["message"] = "Internal error";
-                    (*callbackPtr)(HttpResponse::newHttpJsonResponse(std::move(json)));
+                    (*callbackPtr)(
+                        HttpResponse::newHttpJsonResponse(std::move(json)));
                 }
                 }
             } >>
             } >>
             [callbackPtr, counter](const DrogonDbException &e) {
             [callbackPtr, counter](const DrogonDbException &e) {

+ 3 - 3
frameworks/C++/drogon/drogon_benchmark/controllers/UpdatesCtrlRaw.cc

@@ -49,16 +49,16 @@ void UpdatesCtrlRaw::update(
     for (auto const &w : *results)
     for (auto const &w : *results)
     {
     {
         auto randId = rand() % 10000 + 1;
         auto randId = rand() % 10000 + 1;
-        sqlBinder << w.getValueOfId();
+        sqlBinder << w.getId();
         sqlBinder << randId;
         sqlBinder << randId;
         Json::Value world;
         Json::Value world;
-        world["id"] = w.getValueOfId();
+        world["id"] = w.getId();
         world["randomnumber"] = randId;
         world["randomnumber"] = randId;
         json.append(std::move(world));
         json.append(std::move(world));
     }
     }
     for (auto const &w : *results)
     for (auto const &w : *results)
     {
     {
-        sqlBinder << w.getValueOfId();
+        sqlBinder << w.getId();
     }
     }
 
 
     sqlBinder >> [callbackPtr,
     sqlBinder >> [callbackPtr,

+ 1 - 2
frameworks/C++/drogon/drogon_benchmark/controllers/UpdatesCtrlRaw.h

@@ -1,5 +1,5 @@
 #pragma once
 #pragma once
-#include "models/World.h"
+#include "World_raw.h"
 #include <drogon/HttpSimpleController.h>
 #include <drogon/HttpSimpleController.h>
 #include <drogon/IOThreadStorage.h>
 #include <drogon/IOThreadStorage.h>
 #include <map>
 #include <map>
@@ -7,7 +7,6 @@
 #include <memory>
 #include <memory>
 
 
 using namespace drogon;
 using namespace drogon;
-using namespace drogon_model::hello_world;
 
 
 class UpdatesCtrlRaw : public drogon::HttpSimpleController<UpdatesCtrlRaw>
 class UpdatesCtrlRaw : public drogon::HttpSimpleController<UpdatesCtrlRaw>
 {
 {

+ 34 - 0
frameworks/C++/drogon/drogon_benchmark/controllers/World_raw.h

@@ -0,0 +1,34 @@
+#pragma once
+#include <drogon/orm/Row.h>
+#include <drogon/orm/Field.h>
+#include <json/json.h>
+
+using namespace drogon::orm;
+class World
+{
+  public:
+    explicit World(const Row &r) noexcept
+        : id_(r[(size_t)0].as<int32_t>()),
+          randomNumber_(r[(size_t)1].as<int32_t>())
+    {
+    }
+    inline Json::Value toJson() const
+    {
+        Json::Value ret;
+        ret["id"] = id_;
+        ret["randomnumber"] = randomNumber_;
+        return ret;
+    }
+    inline int32_t getId() const noexcept
+    {
+        return id_;
+    }
+    inline int32_t getRandomnumber() const noexcept
+    {
+        return randomNumber_;
+    }
+
+  private:
+    int32_t id_;
+    int32_t randomNumber_;
+};