Checkpointing work, fighting with cmake
This commit is contained in:
@@ -1,9 +1,15 @@
|
|||||||
project(pistache NONE)
|
|
||||||
include(ExternalProject)
|
include(ExternalProject)
|
||||||
|
|
||||||
ExternalProject_Add(pistache
|
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_CURRENT_SOURCE_DIR}/external)
|
||||||
|
|
||||||
|
ExternalProject_Add(pistache_extern
|
||||||
GIT_REPOSITORY https://github.com/pistacheio/pistache.git
|
GIT_REPOSITORY https://github.com/pistacheio/pistache.git
|
||||||
GIT_TAG master
|
GIT_TAG master
|
||||||
|
#CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
|
||||||
INSTALL_COMMAND ""
|
INSTALL_COMMAND ""
|
||||||
TEST_COMMAND ""
|
|
||||||
)
|
)
|
||||||
|
# include_directories(${EXTERNAL_INSTALL_LOCATION}/include)
|
||||||
|
# link_directories(${EXTERNAL_INSTALL_LOCATION}/lib)
|
||||||
|
|
||||||
|
#add_library(pistache STATIC IMPORTED GLOBAL)
|
||||||
|
#SET_PROPERTY(TARGET pistache IMPORTED_LOCATION ${EXTERNA_INSTALL_LOCATION})
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
project(daggy)
|
project(daggy)
|
||||||
|
|
||||||
|
ExternalProject_Add_StepDependencies(pistache_extern build)
|
||||||
|
|
||||||
file(GLOB SOURCES src/*.cpp)
|
file(GLOB SOURCES src/*.cpp)
|
||||||
add_library(daggy SHARED ${SOURCES})
|
add_library(${PROJECT_NAME} SHARED ${SOURCES})
|
||||||
target_include_directories(daggy PUBLIC include)
|
target_include_directories(${PROJECT_NAME} PUBLIC include)
|
||||||
|
add_dependencies(${PROJECT_NAME} pistache_extern)
|
||||||
|
target_link_libraries(${PROJECT_NAME} pistache_static pthread)
|
||||||
|
|||||||
@@ -29,8 +29,10 @@ namespace daggy {
|
|||||||
|
|
||||||
class Executor {
|
class Executor {
|
||||||
public:
|
public:
|
||||||
Executor(size_t maxParallelism) : maxParallelism_(maxPA
|
Executor(size_t maxParallelism) : maxParallelism_(maxParallelism);
|
||||||
virtual const std::string getName() const = 0;
|
virtual const std::string getName() const = 0;
|
||||||
|
|
||||||
|
// This will block if the executor is full
|
||||||
virtual std::future<TaskResult> runTask(Task & task) = 0;
|
virtual std::future<TaskResult> runTask(Task & task) = 0;
|
||||||
private:
|
private:
|
||||||
size_t maxParallelism_;
|
size_t maxParallelism_;
|
||||||
|
|||||||
29
daggy/include/daggy/Server.hpp
Normal file
29
daggy/include/daggy/Server.hpp
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <pistache/description.h>
|
||||||
|
#include <pistache/endpoint.h>
|
||||||
|
#include <pistache/http.h>
|
||||||
|
|
||||||
|
#include <pistache/thirdparty/serializer/rapidjson.h>
|
||||||
|
|
||||||
|
namespace daggy {
|
||||||
|
class Server {
|
||||||
|
public:
|
||||||
|
Server(Address addr)
|
||||||
|
: endpoint_(addr)
|
||||||
|
, desc("Daggy API", "0.1")
|
||||||
|
{}
|
||||||
|
|
||||||
|
void init(int threads = 1);
|
||||||
|
void start();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void createDescription();
|
||||||
|
|
||||||
|
|
||||||
|
Pistache::Http::Endpoint endpoint_;
|
||||||
|
Pistache::Rest::Description desc_;
|
||||||
|
Pistache::Router router_;
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
53
daggy/src/Server.cpp
Normal file
53
daggy/src/Server.cpp
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
#include <daggy/Server.hpp>
|
||||||
|
|
||||||
|
namespace daggy {
|
||||||
|
void Server::init(int threads = 1) {
|
||||||
|
auto opts = Http::Endpoint::options()
|
||||||
|
.threads(threads)
|
||||||
|
;
|
||||||
|
endpoint_->init(opts);
|
||||||
|
createDescription();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Server::start() {
|
||||||
|
router.initFromDescription(desc_);
|
||||||
|
|
||||||
|
httpEndpoint->setHandler(router.handler());
|
||||||
|
httpEndpoint->serve();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Server::createDescription() {
|
||||||
|
desc_
|
||||||
|
.info()
|
||||||
|
.license("Apache", "http://www.apache.org/licenses/LICENSE-2.0")
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
auto backendErrorResponse = desc_.response(Http::Code::Internal_Server_Error, "An error occured with the backend");
|
||||||
|
|
||||||
|
desc_
|
||||||
|
.schemes(Rest::Scheme::Http)
|
||||||
|
.basePath("/v1")
|
||||||
|
.produces(MIME(Application, Json))
|
||||||
|
.consumes(MIME(Application, Json));
|
||||||
|
|
||||||
|
desc_
|
||||||
|
.route(desc_.get("/ready"))
|
||||||
|
.bind(&Generic::handleReady)
|
||||||
|
.response(Http::Code::Ok, "Response to the /ready call")
|
||||||
|
.hide();
|
||||||
|
|
||||||
|
auto versionPath = desc_.path("/v1");
|
||||||
|
|
||||||
|
auto accountsPath = versionPath.path("/accounts");
|
||||||
|
|
||||||
|
/*
|
||||||
|
accountsPath
|
||||||
|
.route(desc_.get("/all"))
|
||||||
|
.bind(&BankerService::retrieveAllAccounts, this)
|
||||||
|
.produces(MIME(Application, Json), MIME(Application, Xml))
|
||||||
|
.response(Http::Code::Ok, "The list of all account");
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user