-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
600d69f
commit 5b69097
Showing
5 changed files
with
131 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
# Table of contents | ||
|
||
* [Main](Projects/flipback/reduct-storage/reduct-cpp/docs/README.mdflipback/reduct-storage/reduct-cpp/docs/README.md) | ||
* [Quick Start](Projects/flipback/reduct-storage/reduct-cpp/docs/quick-start.mdack/reduct-storage/reduct-cpp/docs/quick-start.md) | ||
* [Main](README.md) | ||
* [Quick Start](../quick-start.md) | ||
|
||
## Reference | ||
|
||
* [API Reference](Projects/flipback/reduct-storage/reduct-cpp/docs/referenceflipback/reduct-storage/reduct-cpp/docs/reference/api-reference.md) | ||
* [API Reference](../reference/api-reference.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
# Quick Start | ||
|
||
## Requirements | ||
|
||
Reduct Storage C++ SDK is written in C++20 and uses cmake as a build system. To install it, you need: | ||
|
||
* C++ compiler with C++20 support (we use GCC-11.2) | ||
* cmake 3.18 or higher | ||
* conan 1.40 or higher (it is optional, but [**conan**](https://conan.io) is cool!) | ||
|
||
Currently, we test only Linux AMD64, but if you need to port it to another OS or platform, feel free to make an [issue](https://github.com/reduct-storage/reduct-cpp/issues/new/choose). | ||
|
||
## Installing | ||
|
||
To install the SDK, you should use the classical approach: | ||
|
||
``` | ||
git clone https://github.com/reduct-storage/reduct-cpp.git | ||
cd reduct-cpp | ||
mkdir build && cd build | ||
cmake -DCMAKE_BUILD_TYPE=Release .. | ||
cmake --build . | ||
sudo cmake --build . --target install | ||
``` | ||
|
||
## Simple Application | ||
|
||
Let's create a simple C++ application which connects to the storage, creates a bucket and writes/reads some data. We need two files: | ||
|
||
``` | ||
touch CMakeLists.txt main.cc | ||
``` | ||
|
||
I'm sure you're familiar to cmake, so I don't have to explain all the detail. The `CMakeLists.txt` should look like this: | ||
|
||
{% code title="CMakeLists.txt" %} | ||
```cmake | ||
cmake_minimum_required(VERSION 3.18) | ||
project(ReductCppExamples) | ||
set(CMAKE_CXX_STANDARD 20) | ||
find_package(ReductCpp 0.1.0) | ||
add_executable(usage-example main.cc) | ||
target_link_libraries(usage-example ${REDUCT_CPP_LIBRARIES}) | ||
``` | ||
{% endcode %} | ||
|
||
And now the code in `main.cc`: | ||
|
||
```cpp | ||
#include <reduct/client.h> | ||
|
||
#include <iostream> | ||
|
||
using reduct::IBucket; | ||
using reduct::IClient; | ||
|
||
int main() { | ||
auto client = IClient::Build("http://127.0.0.1:8383"); | ||
// Create a bucket | ||
auto [bucket, create_err] = | ||
client->CreateBucket("bucket"); | ||
if (create_err) { | ||
std::cerr << "Error: " << create_err; | ||
return -1; | ||
} | ||
|
||
// Write some data | ||
IBucket::Time ts = IBucket::Time::clock::now(); | ||
[[maybe_unused]] auto write_err = bucket->Write("entry-1", "some_data1", ts); | ||
|
||
// Read data | ||
auto [blob, read_err] = bucket->Read("entry-1", ts); | ||
if (!read_err) { | ||
std::cout << "Read blob: " << blob << std::endl; | ||
} | ||
} | ||
``` | ||
|
||
To compile the example, we use the same idiom: | ||
|
||
``` | ||
mkdir build && cd build | ||
cmake .. | ||
cmake --build . | ||
``` | ||
|
||
Let's run the code, but before you need to run the storage. For this, we have to run it as a Docker container: | ||
|
||
``` | ||
docker run -p 8383:8383 ghcr.io/reduct-storage/reduct-storage:main | ||
``` | ||
|
||
Now you can launch the example: | ||
|
||
``` | ||
./usage-example | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# API Reference | ||
|
||
Dive into the specifics of each API endpoint by checking out our complete documentation. | ||
|
||
## Pets | ||
|
||
All the methods associated with `CRUD`ing some pets. Which isn't as weird as it sounds: | ||
|
||
{% content-ref url="broken-reference/" %} | ||
[broken-reference](broken-reference/) | ||
{% endcontent-ref %} | ||
|
||
## Users | ||
|
||
Everything related to users: | ||
|
||
{% content-ref url="broken-reference/" %} | ||
[broken-reference](broken-reference/) | ||
{% endcontent-ref %} | ||
|
||
{% hint style="info" %} | ||
**Good to know:** Using the 'Page Link' block lets you link directly to a page. If this page's name, URL or parent location changes, the reference will be kept up to date. You can also mention a page – like [broken-reference](broken-reference/ "mention") – if you don't want a block-level link. | ||
{% endhint %} |