This repo shows the basic usages of dragonboat in C++ projects and is not suitable for benchmark
This repo contains C++ examples for dragonboat.
The original repo of dragonboat examples can be found here
Details can be found in each folder.
- helloworld
- multigroup
- *concurrent statemachine
- ondisk
- *ioservice
Please rebuild the binding using the master branch of dragonboat
- support all new features in nodehost.go with both sync/async version
- support concurrent & on-disk statemachines with batchedUpdate method
- prepareSnapshot & saveSnapshot take/return a
void*
to represent an arbitrary type - clients can specify both .so file name and factory name when starting cluster from a plugin
StartCluster
now accepts a functional factory which allows caller to parse both C-style functions and lambda expressions
- we also have a plan to implement a Python binding
- issues are welcome both here and dragonboat
- GCC with C++11 support
- cmake
- dragonboat C++ binding
Instructions can be found here.
The dragonboat C++ binding is based on CGo, thus its performance is worse than the original Go interface. Please refer to Adventures in Cgo Performance for more details.
mkdir build
cd build && cmake ..
make
- example - ondisk is a RocksDB based key-value store thus RocksDB is required.
Start three instances on the same machine in three different terminals:
./dragonboat_cpp_example -nodeid 1
./dragonboat_cpp_example -nodeid 2
./dragonboat_cpp_example -nodeid 3