GithubHelp home page GithubHelp logo

jgarzik / kvdbd Goto Github PK

View Code? Open in Web Editor NEW
18.0 5.0 8.0 319 KB

API service exporting embedded key/value databases to remote users

License: MIT License

Rust 98.56% Dockerfile 0.93% Shell 0.51%
rust rust-lang rest-api key-value key-value-store server json microservice protocol-buffers protobuf protobuf3 daemon

kvdbd's Introduction

kvdbd

Daemon that enables reading/writing of flat-file key/value databases available via HTTP API, using REST/JSON or Protobufs.

Goals

  • "NoSQL databases go from filesystem to docker microservice"
  • Written in safe rust
  • Can be queried by stock HTTP clients
  • Modern HTTP service with threads, HTTP/2 etc.
  • Beyond Get/Put/Delete, expose db-specific operations such as transactions or batch-update.
  • Access multiple databases simultaneously from a single HTTP endpoint.
  • Support multiple database back-ends (sled, lmdb, more soon)
  • Docker-friendly Zero configuration mode

Documentation

  • Requirements: Rust 2018+ and protoc compiler.
  • Quick Start: see below
  • Configuration: config.md
  • Remote HTTP API: api.md

Using kvdbd

From cargo

Standard rust cargo multi-binary setup:

$ cargo build
$ cargo run --bin kvdbd

From docker

Zeroconf docker example, with sled database stored on docker volume dbdata:

$ docker volume create dbdata
$ docker run --rm -p 8080:8080 -v dbdata:/data jgarzik/kvdbd \
	kvdbd --bind-addr 0.0.0.0 --sled /data/sled.db
$ curl http://127.0.0.1:8080/ | json_pp

Testing

Integration testing is performed via a separate binary, tester.

$ cargo run --bin tester

Other projects

Unrelated projects with similar names:

kvdbd's People

Contributors

jgarzik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

kvdbd's Issues

Improve error propagation

Propagate db-specific errors up the stack, giving the end user/devop improved diagnostics for any error condition (which are rare, in production).

This may imply providing our own generic Error and Result.

Protobuf helper binary

Small helper binary to encode/decode our wire protocol via stdin/stdout, e.g.

$ kvdb-pb --encode --op get --key FirstName > /tmp/get-pb.bin
$ curl -X POST --data-binary @/tmp/get-pb.bin http://localhost:8080/api/db/get

API: Prefix filtering, for db iteration

Related to #17

Limit the query to only keys that match a certain prefix.

For b-tree databases, this is easy.
This hash databases, this requires us to filter out non-matches during a full db walk.

Key size limits

Keys for each type of database tend to have size limits, e.g. 4096 bytes.

Validate and check these limits.

Debian/ubuntu packaging

Add control files and other setup necessary to create an OS package for Linux.

  • Debian control files
  • systemd configuration

Publish on Docker Hub

Enable users to discover and use kvdbd directly from Docker Hub.

e.g.

$ docker run -v /path/to/host/dbdir:/data jgarzik/kvdbd kvdbd --sled /data

API: DB Statistics (record count)

Expose ability to query total record count (primarily), and any other useful db metadata.

Record count is often an expensive operation, walking the entire database tree / hash buckets.

JSON and zeroconf ServerConfig structs differ

In zeroconf mode, ServerConfig struct is used.

In JSON config mode, the following is used,

server_cfg = serde_json::from_str(&cfg_text)?;

This creates problems such as the unintended requirement that the ssl section of the config be present, even if using unencrypted HTTP mode.

Dockerize

Create and test project Dockerfile

Fix caching docker build

For some as-yet-not-investigated reason, the double-build technique that enables docker caching, currently commented-out in the Dockerfile, causes the docker build to fail thusly:

   Compiling actix-files v0.1.4
   Compiling kvdbd v0.3.1 (/usr/src/kvdbd)
error: couldn't read src/kvdb-pb.rs: No such file or directory (os error 2)

error: aborting due to previous error

error: Could not compile `kvdbd`.
warning: build failed, waiting for other jobs to finish...
error: couldn't read src/tester.rs: No such file or directory (os error 2)

error: aborting due to previous error

error: Could not compile `kvdbd`.
warning: build failed, waiting for other jobs to finish...
error: build failed
The command '/bin/sh -c cargo build --release' returned a non-zero code: 101

Update protoc version

First noted in #16 - protoc link has disappeared, because we're referencing an older protoc version. Update in travis etc. scripts.

Zero-configuration support

Users should be able to run a fully working server from the command line, with no configuration files, e.g.

$ kvdb --gdbm /path/to/database.dat &
$ sleep 1
$ curl http://127.0.0.1:8080/

Uploading Large values

Large values are likely to present at least two problems:

  1. actix may not buffer more than a chunk, during uploads.
  2. Payload buffered entirely in memory.

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.