Skip to content

Commit

Permalink
GitBook: [#2] No subject
Browse files Browse the repository at this point in the history
  • Loading branch information
atimin authored and gitbook-bot committed Feb 8, 2022
1 parent 600d69f commit 5b69097
Show file tree
Hide file tree
Showing 5 changed files with 131 additions and 76 deletions.
69 changes: 0 additions & 69 deletions README.md

This file was deleted.

8 changes: 4 additions & 4 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ C++ Client SDK is an open-source client for [Reduct Storage](https://reduct-stor

If you're not familiar to [Reduct Storage](https://reduct-storage.dev) and want to give it a try before diving deeper into the detail, jump here

{% content-ref url="quick-start.md" %}
[quick-start.md](Projects/flipback/reduct-storage/reduct-cpp/docs/quick-start.mdack/reduct-storage/reduct-cpp/docs/quick-start.md)
{% content-ref url="../quick-start.md" %}
[quick-start.md](../quick-start.md)
{% endcontent-ref %}

### API Reference

The whole API is documented here:

{% content-ref url="reference/api-reference.md" %}
[api-reference.md](Projects/flipback/reduct-storage/reduct-cpp/docs/referenceflipback/reduct-storage/reduct-cpp/docs/reference/api-reference.md)
{% content-ref url="../reference/api-reference.md" %}
[api-reference.md](../reference/api-reference.md)
{% endcontent-ref %}
6 changes: 3 additions & 3 deletions docs/SUMMARY.md
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)
101 changes: 101 additions & 0 deletions quick-start.md
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
```
23 changes: 23 additions & 0 deletions reference/api-reference.md
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 %}

0 comments on commit 5b69097

Please sign in to comment.