Git Product home page Git Product logo

reduct-cpp's Introduction

ReductStore Client SDK for C++

GitHub release (latest SemVer) GitHub Workflow Status

The ReductStore Client SDK for C++ is an open source client for ReductStore written in C++20. It allows developers to easily interact with the database from their C++ applications.

Features

  • Written in C++20
  • Support ReductStore HTTP API v1.3
  • Support HTTP and HTTPS protocols
  • Exception free
  • Support Linux AMD64

Example

Here is a simple example of how to use the ReductStore Client SDK for C++ to create a bucket, write data to it, and read the data back:

#include <reduct/client.h>

#include <iostream>

using reduct::IBucket;
using reduct::IClient;

int main() {
  auto client = IClient::Build("https://play.reduct.store");
  // Create a bucket
  auto [bucket, create_err] = client->GetOrCreateBucket("bucket");
  if (create_err) {
    std::cerr << "Error: " << create_err;
    return -1;
  }

  // Write some data
  auto ts = IBucket::Time::clock::now();
  [[maybe_unused]] auto write_err = bucket->Write("entry-1", ts, [](auto rec) { rec->WriteAll("some_data1"); });

  // Read data via timestamp
  auto read_err = bucket->Read("entry-1", ts, [](auto rec) {
        std::cout << "Read blob: " <<  rec->ReadAll() << std::endl;
  });


  // Walk through the data
  err = bucket->Query("entry-1", std::nullopt, IBucket::Time::clock::now(), {}, [](auto&& record) {
    std::string blob;

    auto read_err = record.Read([&blob](auto chunk) {
      blob.append(chunk);
      return true;
    });

    if (!read_err) {
      std::cout << "Read blob: " << blob;
    }

    return true;
  });
}

Build

  • GCC 11.2 or higher (support C++20)
  • CMake 3.18 or higher
  • ZLib
  • OpenSSL 1.1 or 3.0
  • Conan 1.58 (optionally)

To build the library, follow these steps:

git clone https://github.com/reductstore/reduct-cpp.git
cd reduct-cpp
mkdir build && cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
sudo cmake --build . --target install

CMake tries to use the conan package manager if it is installed. If it isn't, it downloads all the dependencies by using FetchContent. To use ReductStore SDK you need only to use find_pacakge in your cmake lists:

find_package(ReductCpp)

References

reduct-cpp's People

Contributors

atimin avatar mounte avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.