Commit c2e35dab authored by Giorgio Azzinnaro's avatar Giorgio Azzinnaro

fixed profanedb server

parent e844254f
......@@ -22,7 +22,7 @@ if(BUILD_PROFANEDB_SERVER)
set(GRPC_H db.grpc.pb.h)
add_library(profanedb_grpc STATIC ${GRPC_CC} ${GRPC_H})
target_link_libraries(profanedb_grpc profanedb_protobuf ${GRPC_LIBRARIES})
target_link_libraries(profanedb_grpc profanedb_protobuf grpc++) # TODO FindgRPC doesn't work
if(BUILD_SHARED_LIBS)
set_target_properties(profanedb_grpc PROPERTIES POSITION_INDEPENDENT_CODE ON)
......
......@@ -65,7 +65,7 @@ Server::Server()
auto marshaller = std::make_shared<ProtobufMarshaller>(storage, loader);
service = std::make_unique<DbServiceImpl>(storage, marshaller);
service = std::make_unique<DbServiceImpl>(storage, marshaller, loader);
}
Server::~Server()
......@@ -96,10 +96,12 @@ void Server::HandleRpcs()
Server::DbServiceImpl::DbServiceImpl(
std::shared_ptr<RocksStorage> storage,
std::shared_ptr<ProtobufMarshaller> marshaller)
std::shared_ptr<ProtobufMarshaller> marshaller,
std::shared_ptr<Loader> loader)
: rocksdbStorage(storage)
, protobufMarshaller(marshaller)
, profane(std::make_unique< profanedb::Db<Message> >(storage, marshaller))
, loader(loader)
{
}
......@@ -121,7 +123,9 @@ Status Server::DbServiceImpl::Put(ServerContext * context, const PutReq * reques
// (which comes with `type.googleapis.com/` prepended)
std::string type = request->serializable().type_url();
Message * unpackedMessage =
this->protobufMarshaller->CreateMessage(ProtobufMarshaller::SCHEMA, type.substr(type.rfind('/')+1, std::string::npos));
this->loader
->CreateMessage(Loader::SCHEMA, type.substr(type.rfind('/')+1, std::string::npos))
->New();
request->serializable().UnpackTo(unpackedMessage);
BOOST_LOG_TRIVIAL(trace) << "Unpacked message" << std::endl << unpackedMessage->DebugString();
......
......@@ -57,7 +57,8 @@ private:
public:
DbServiceImpl(
std::shared_ptr<profanedb::vault::rocksdb::Storage> storage,
std::shared_ptr<profanedb::format::protobuf::Marshaller> marshaller);
std::shared_ptr<profanedb::format::protobuf::Marshaller> marshaller,
std::shared_ptr<profanedb::format::protobuf::Loader> loader);
grpc::Status Get(
grpc::ServerContext * context,
......@@ -79,6 +80,8 @@ private:
std::shared_ptr<profanedb::format::protobuf::Marshaller> protobufMarshaller;
std::unique_ptr< profanedb::Db<google::protobuf::Message> > profane;
std::shared_ptr<profanedb::format::protobuf::Loader> loader;
};
std::unique_ptr<DbServiceImpl> service;
};
......
......@@ -13,7 +13,6 @@ using ProtobufMarshaller = profanedb::format::protobuf::Marshaller;
using profanedb::vault::Storage;
using profanedb::protobuf::MessageTreeNode;
// FIXME Should mock this
using RocksStorage = profanedb::vault::rocksdb::Storage;
using google::protobuf::Message;
......@@ -22,6 +21,7 @@ struct Format
{
std::shared_ptr<Loader> loader;
std::shared_ptr<ProtobufMarshaller> marshaller;
std::shared_ptr<RocksStorage> storage;
Format()
{
......@@ -31,7 +31,7 @@ struct Format
rocksdb::DB *rocks;
rocksdb::DB::Open(rocksOptions, "/tmp/profane", &rocks);
auto storage = std::make_shared<RocksStorage>(std::unique_ptr<rocksdb::DB>(rocks));
this->storage = std::make_shared<RocksStorage>(std::unique_ptr<rocksdb::DB>(rocks));
auto includeSourceTree = new Loader::RootSourceTree{
"/usr/include", "/home/giorgio/Documents/ProfaneDB/ProfaneDB/src"};
......
......@@ -38,7 +38,7 @@ message KeyableNested {
KeyInt nested_keyable = 2;
}
// TODO A Key can also be a message
// A Key can also be a message
message MessageAsKey {
message MyKeyObj {
int32 int = 1;
......@@ -54,7 +54,7 @@ message KeyableInNonkeyableNested {
message NonkeyableNested {
message KeyableNested {
int64 int_key = 1;
int64 int_key = 1 [ (profanedb.protobuf.options).key = true ];
}
KeyableNested nested_keyable = 1;
}
......
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