Schema definition
Multiple examples of schema definition can be found in ProfaneDB tests.
Let’s give a look at how a message would look before and after it’s turned into a ProfaneDB schema.
message User {
string email = 1;
string name = 2;
Date date_of_birth = 3;
message Date { ... }
}
We have this existing message definition.
Now to select a key a unique field is needed.
In this case, obviously email
.
import "profanedb/protobuf/options.proto"
message User {
string email = 1 [(profanedb.protobuf.options).key = true ];
}
First of all, profanedb/protobuf/options.proto
is imported.
If ProfaneDB was installed correctly,
this should reside in /usr/include
alongside google/protobuf/*.proto
,
so it’s commonly imported when running protoc
.
After that the key
custom option can be applied.
Note that only one field for each message should be marked as key
Configuration
Currently ProfaneDB has a very simple configuration.
(Later on more specific RocksDB options will be added in configuration file).
-h [ --help ] Display this help message
--log_level arg trace, debug, info, warning, error, fatal
-I [ --proto_path ] arg Specify the paths to import proto files
(google/protobuf/..., profanedb/protobuf/...)
-S [ --schema_path ] arg Specify the paths to load the user defined schema
--rocksdb_path arg Set the path RocksDB uses to store its content
Let’s focus on the last 3 options:
proto_path
:
google/protobuf/*.proto
andprofanedb/protobuf/*.proto
must be reachable from here.
Multiple paths can be defined.schema_path
: the most important option, here is the root of our schema definition.rocksdb_path
: this is where RocksDB will store its files.
It must be consistent across restarts.
gRPC
gRPC is used to connect with ProfaneDB.
(ProfaneDB can otherwise be embedded)
A simple GET
, PUT
. DELETE
interface is provided.
There is a Python sample in the code.
However, it is probably easier to just look at the .proto file where the interface is defined.
Messages are stored and retrieved as google.protobuf.Any
, every language has its methods to pack/unpack messages.
See Protobuf documentation.