Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ find_package(Boost REQUIRED COMPONENTS system serialization iostreams)
find_package(duckdb REQUIRED)
find_package(LibLZMA REQUIRED)
find_package(nlohmann_json REQUIRED)
find_package(Poco REQUIRED COMPONENTS Net Util JSON)
find_package(Crow REQUIRED COMPONENTS Net Util JSON)
find_package(roaring REQUIRED)
find_package(spdlog REQUIRED)
find_package(TBB REQUIRED)
Expand Down Expand Up @@ -117,9 +117,7 @@ target_link_libraries(
TBB::tbb
${yaml-cpp_LIBRARIES}
zstd::libzstd_static
Poco::Net
Poco::Util
Poco::JSON
Crow::Crow
re2::re2
)

Expand Down
26 changes: 4 additions & 22 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ class SiloRecipe(ConanFile):
settings = "os", "compiler", "build_type", "arch"

requires = [
"asio/1.29.0",
"boost/1.82.0",
"crowcpp-crow/1.2.0",
"duckdb/1.0.0",
"poco/1.13.3",
"hwloc/2.9.3",
"onetbb/2021.10.0",
"nlohmann_json/3.11.2",
"gtest/cci.20210126",
Expand Down Expand Up @@ -73,25 +73,7 @@ class SiloRecipe(ConanFile):
"boost/*:without_type_erasure": True,
"boost/*:without_wave": True,

"poco/*:shared": False,
"poco/*:enable_json": True,
"poco/*:enable_net": True,
"poco/*:enable_util": True,

"poco/*:enable_crypto": False,
"poco/*:enable_activerecord": False,
"poco/*:enable_active_record": False,
"poco/*:enable_data": False,
"poco/*:enable_data_mysql": False,
"poco/*:enable_data_postgresql": False,
"poco/*:enable_data_sqlite": False,
"poco/*:enable_encodings": False,
"poco/*:enable_jwt": False,
"poco/*:enable_mongodb": False,
"poco/*:enable_netssl": False,
"poco/*:enable_redis": False,
"poco/*:enable_xml": False,
"poco/*:enable_zip": False,
"crowcpp-crow/*:shared": False,

"re2/*:shared": False,

Expand All @@ -102,12 +84,12 @@ def generate(self):
deps = CMakeDeps(self)
deps.set_property("boost", "cmake_find_mode", "both")
deps.set_property("duckdb", "cmake_find_mode", "both")
deps.set_property("crowcpp-crow", "cmake_find_mode", "both")
deps.set_property("gtest", "cmake_find_mode", "both")
deps.set_property("hwloc", "cmake_find_mode", "both")
deps.set_property("nlohmann_json", "cmake_find_mode", "both")
deps.set_property("onetbb", "cmake_find_mode", "both")
deps.set_property("pcre2", "cmake_find_mode", "both")
deps.set_property("poco", "cmake_find_mode", "both")
deps.set_property("roaring", "cmake_find_mode", "both")
deps.set_property("spdlog", "cmake_find_mode", "both")
deps.set_property("yaml-cpp", "cmake_find_mode", "both")
Expand Down
5 changes: 1 addition & 4 deletions endToEndTests/test/query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ describe('The /query endpoint', () => {
});

it('should return a method not allowed response when sending a GET request', async () => {
await server.get('/query').send().expect(405).expect('Content-Type', 'application/json').expect({
error: 'Method not allowed',
message: 'GET is not allowed on resource /query',
});
await server.get('/query').send().expect(405);
});

it('should return a bad request response when POSTing an invalid JSON', async () => {
Expand Down
12 changes: 2 additions & 10 deletions endToEndTests/test/unknownUrl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@ import { server } from './common.js';

describe('SILO', () => {
it('should return a proper 404 message when GETting an unknown url', async () => {
await server
.get('/unknown-url')
.expect(404)
.expect('Content-Type', 'application/json')
.expect({ error: 'Not found', message: 'Resource /unknown-url does not exist' });
await server.get('/unknown-url').expect(404);
});

it('should return a proper 404 message when POSTing to an unknown url', async () => {
await server
.post('/unknown-url')
.expect(404)
.expect('Content-Type', 'application/json')
.expect({ error: 'Not found', message: 'Resource /unknown-url does not exist' });
await server.post('/unknown-url').expect(404);
});
});
12 changes: 12 additions & 0 deletions include/external/roaring_include_wrapper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#pragma once

// This wrapper is required because roaring is currently not well-behaved when #include'd.
// Importantly, it includes system headers and previously sets preprocessor macro's
// to ensure portability of the included headers.
// However, this prevents other libraries to use features of the detected platform.
// See https://github.com/RoaringBitmap/CRoaring/issues/690

#include <netdb.h>
#include <netinet/in.h>

#include <roaring/roaring.hh>
2 changes: 1 addition & 1 deletion include/silo/api/active_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ActiveDatabase {

void setActiveDatabase(silo::Database&& new_database);

std::shared_ptr<silo::Database> getActiveDatabase();
std::shared_ptr<const silo::Database> getActiveDatabase();
};

} // namespace silo::api
4 changes: 1 addition & 3 deletions include/silo/api/api.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#pragma once

#include <Poco/Util/ServerApplication.h>

#include "silo/config/runtime_config.h"

namespace silo::api {

class Api : public Poco::Util::ServerApplication {
class Api {
public:
int runApi(const silo::config::RuntimeConfig& runtime_config);
};
Expand Down
9 changes: 9 additions & 0 deletions include/silo/api/crow_spdlog_adapter.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include <crow.h>

class CrowSpdlogAdapter : public crow::ILogHandler {
public:
CrowSpdlogAdapter() {}
void log(std::string message, crow::LogLevel level);
};
18 changes: 12 additions & 6 deletions include/silo/api/database_directory_watcher.h
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
#pragma once

#include <atomic>
#include <filesystem>
#include <optional>

#include <Poco/Timer.h>
#include <crow.h>

#include "silo/api/request_handler_factory.h"
#include "silo/api/active_database.h"
#include "silo/common/data_version.h"

namespace silo::api {

class DatabaseDirectoryWatcher {
std::atomic<bool> running;
std::atomic<bool> stopped;
std::filesystem::path path;
std::shared_ptr<ActiveDatabase> database_handle;
Poco::Timer timer;
std::shared_ptr<ActiveDatabase> active_database;

public:
DatabaseDirectoryWatcher(
std::filesystem::path path,
std::shared_ptr<ActiveDatabase> database_handle
std::shared_ptr<ActiveDatabase> active_database
);

void checkDirectoryForData(Poco::Timer& timer);
void start();

void stop();

void checkDirectoryForData();

static std::optional<silo::DataVersion> checkValidDataSource(const std::filesystem::path& path);

Expand Down
49 changes: 0 additions & 49 deletions include/silo/api/error_request_handler.h

This file was deleted.

21 changes: 9 additions & 12 deletions include/silo/api/info_handler.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
#pragma once

#include <Poco/Net/HTTPServerRequest.h>
#include <Poco/Net/HTTPServerResponse.h>
#include <crow.h>

#include "active_database.h"
#include "rest_resource.h"
#include "silo/api/active_database.h"
#include "silo/api/rest_resource.h"

namespace silo::api {

class InfoHandler : public RestResource {
private:
std::shared_ptr<Database> database;

class InfoHandler {
public:
explicit InfoHandler(std::shared_ptr<Database> database);

void get(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response)
override;
static void get(
std::shared_ptr<const Database> database,
crow::request& request,
crow::response& response
);
};
} // namespace silo::api
22 changes: 9 additions & 13 deletions include/silo/api/lineage_definition_handler.h
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
#pragma once

#include <Poco/Net/HTTPServerRequest.h>
#include <Poco/Net/HTTPServerResponse.h>

#include "active_database.h"
#include "rest_resource.h"
#include "silo/api/active_database.h"

namespace silo::api {

class LineageDefinitionHandler : public RestResource {
private:
std::shared_ptr<Database> database;
std::string column_name;
class LineageDefinitionHandler {
std::shared_ptr<ActiveDatabase> active_database;

public:
explicit LineageDefinitionHandler(std::shared_ptr<Database> database, std::string column_name);

void get(Poco::Net::HTTPServerRequest& request, Poco::Net::HTTPServerResponse& response)
override;
static void get(
std::shared_ptr<const Database> database,
crow::request& request,
crow::response& response,
const std::string& column_name
);
};

} // namespace silo::api
23 changes: 0 additions & 23 deletions include/silo/api/logging_request_handler.h

This file was deleted.

16 changes: 16 additions & 0 deletions include/silo/api/logging_request_middleware.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

#include <crow.h>

namespace silo::api {

class LoggingRequestMiddleware {
public:
public:
struct context {};

void before_handle(crow::request& request, crow::response& response, context& context);

void after_handle(crow::request& request, crow::response& response, context& context);
};
} // namespace silo::api
Loading
Loading