Commit ff3221b3 authored by Giorgio Azzinnaro's avatar Giorgio Azzinnaro

test boost::injector

parent 4b505d69
......@@ -43,6 +43,8 @@ public:
// Paths are available for Loader to populate its Pool;
class RootSourceTree : public google::protobuf::compiler::DiskSourceTree {
friend Loader;
public:
RootSourceTree(std::initializer_list<boost::filesystem::path> paths);
private:
......
......@@ -19,8 +19,24 @@
#include "server.h"
using profanedb::format::protobuf::Loader;
using ProtobufMarshaller = profanedb::format::protobuf::Marshaller;
using RocksStorage = profanedb::vault::rocksdb::Storage;
using google::protobuf::Message;
using grpc::ServerBuilder;
using rocksdb::DB;
profanedb::server::Server::Server()
{
boost::di::bind<profanedb::format::Marshaller<Message>>().to<ProtobufMarshaller>();
boost::di::bind<profanedb::vault::Storage>().to<RocksStorage>();
auto injector = boost::di::make_injector();
// service = std::make_unique<DbServiceImpl>(new DbServiceImpl(
// injector.create< profanedb::Db<google::protobuf::Message> >());
}
profanedb::server::Server::~Server()
......@@ -32,10 +48,10 @@ void profanedb::server::Server::Run()
{
std::string address("0.0.0.0:50051");
grpc::ServerBuilder builder;
ServerBuilder builder;
builder.AddListeningPort(address, grpc::InsecureServerCredentials());
builder.RegisterService(&service);
builder.RegisterService(service.get());
server = builder.BuildAndStart();
......@@ -49,7 +65,7 @@ void profanedb::server::Server::HandleRpcs()
server->Wait();
}
profanedb::server::Server::DbServiceImpl::DbServiceImpl(profanedb::Db<google::protobuf::Message> & profanedb)
profanedb::server::Server::DbServiceImpl::DbServiceImpl(profanedb::Db<Message> & profanedb)
: profanedb(profanedb)
{
}
......
......@@ -20,13 +20,17 @@
#ifndef PROFANEDB_STORAGE_SERVER_H
#define PROFANEDB_STORAGE_SERVER_H
#include <profanedb/protobuf/db.pb.h>
#include <profanedb/protobuf/db.grpc.pb.h>
#include <grpc++/grpc++.h>
#include <grpc/support/log.h>
#include <profanedb/db.h>
#include <boost/di.hpp>
#include <profanedb/protobuf/db.pb.h>
#include <profanedb/protobuf/db.grpc.pb.h>
#include <profanedb/format/protobuf/marshaller.h>
#include <profanedb/vault/rocksdb/storage.h>
#include <profanedb/db.h>
namespace profanedb {
namespace server {
......@@ -58,7 +62,7 @@ private:
private:
profanedb::Db<google::protobuf::Message> & profanedb;
};
DbServiceImpl service;
std::unique_ptr<DbServiceImpl> service;
};
}
......
add_library(profanedb_vault rocksdb/storage.cpp)
target_link_libraries(profanedb_vault profanedb_protobuf)
target_link_libraries(profanedb_vault profanedb_protobuf ${ROCKSDB_LIBRARIES})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment