Skip to content

Commit

Permalink
Merge branch 'master' into feature-encryption
Browse files Browse the repository at this point in the history
  • Loading branch information
Clint.Network authored Feb 28, 2020
2 parents cbf2d07 + 7791265 commit e0766a3
Show file tree
Hide file tree
Showing 11 changed files with 225 additions and 48 deletions.
5 changes: 4 additions & 1 deletion .github/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,7 @@ store:
http:
request_size_limit: 8388608
logging:
level: Info
level: INFO
outputs:
- type: stderr
colored: true
5 changes: 4 additions & 1 deletion .github/lucid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ store:
http:
request_size_limit: 8388608
logging:
level: Info
level: INFO
outputs:
- type: stderr
colored: true
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ Lucid is a KV store using an HTTP API, the server part is build with `warp` and

## Community

For any question, you can contact us on @Gitter at https://gitter.im/lucidkv
For any question, you can contact us on Discord [here](https://discord.gg/mZz67M6).

[![Discord Server](https://img.shields.io/badge/Discord-Server-7289DA)](https://discord.gg/mZz67M6)
62 changes: 62 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[package]
name = "lucid"
description = "A Fast, Secure and Distributed KV store with an HTTP API."
description = "High performance and distributed KV store w/ REST API."
version = "0.1.2"
authors = ["Clint.Network <me@clint.network>", "Jonathan Serra <jonathan@blocs.fr>", "CephalonRho <CephalonRho@gmail.com>", "rigwild <me@rigwild.dev>"]
edition = "2018"
keywords = ["kv", "distributed", "ledger", "kv-store", "key-value", "rest", "http", "swagger", "server-sent-event", "web-ui", "encryption", "persistence", "serpent", "redis"]
keywords = ["kv", "distributed", "ledger", "kv-store", "kv store", "key-value", "key-value store", "rest", "http", "swagger", "server-sent-event", "web-ui", "encryption", "persistence", "serpent", "redis", "redis-like", "compression"]
repository = "https://github.com/lucid-kv/lucid"
readme = "https://github.com/lucid-kv/lucid/blob/master/README.md"
license = "https://github.com/lucid-kv/lucid/blob/master/LICENSE.md"
Expand Down Expand Up @@ -36,8 +36,8 @@ chashmap = "2.2.2"
tree_magic = "0.2.1"
snafu = "0.6.2"
bytes = "0.5.3"
fern = "0.5.9"
hex = "0.3.1"
fern = { version = "0.5.9", features = ["colored", "syslog-4"] }
clap = { version = "2.33.0", features = ["yaml"] }
warp = { version = "0.2.0", features = ["tls"] }
log = { version = "0.4.8", features = ["serde"] }
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
<a href="https://github.com/lucid-kv/lucid/actions?workflow=Lucid"><img src="https://github.com/lucid-kv/lucid/workflows/Lucid/badge.svg" /></a>
<a href="https://www.rust-lang.org/"><img src="https://img.shields.io/badge/Made%20With-Rust-dea584" /></a>
<a href="https://github.com/lucid-kv/lucid/blob/master/LICENSE.md"><img src="https://img.shields.io/badge/license-MIT-lightgrey.svg" /></a>
<a href="https://gitter.im/lucidkv/community"><img src="https://badges.gitter.im/Join%20Chat.svg" /></a>
<a href="https://discord.gg/mZz67M6"><img src="https://img.shields.io/badge/Discord-Server-7289DA" /></a>
</p>
</p>

## Introduction

Lucid is currently in a development stage but we want to achieve a fast, secure and distributed key-value store accessible through an HTTP API, we also want to propose persistence, encryption, WebSocket streaming, replication and a lot of features.
Lucid is currently in a development stage but we plan to make a fast, secure and distributed key-value store accessible through an HTTP API, we also want to propose Persistence, Encryption, SSE streaming, Compression, Replication and more.

## Getting Started

Expand All @@ -36,19 +36,19 @@ $ docker pull lucidkv/lucid
$ docker run -p 7020:7020 -v lucid.yml:/etc/lucid/lucid.yml lucidkv/lucid
```

A demonstration instance is accessible at http://lucid-kv.herokuapp.com (with authentication disabled).
A demonstration instance is accessible at <http://lucid-kv.herokuapp.com> (with authentication disabled).

## Documentation

You can find the official documentation at https://docs.lucid-kv.store.
You can start quickly [here](https://github.com/lucid-kv/lucid/wiki) or get the complete documentation at <https://docs.lucid-kv.store>.

## Works in Progress

You can take a look at the roadmap [here](https://github.com/lucid-kv/lucid/issues/46), we are working on the implementation of persistence and encryption.

## Command Line Interface

You can take a look at the Lucid command line on at https://asciinema.org/a/277538.
You can take a look at the Lucid command line on at <https://asciinema.org/a/277538>.

```
██╗ ██╗ ██╗ ██████╗██╗██████╗ ██╗ ██╗██╗ ██╗
Expand Down
4 changes: 2 additions & 2 deletions src/cli.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Lucid"
author: &author "Written in Rust by Clint.Network (https://github.com/lucid-kv)"
author: &author "Written in Rust, Fork us on GitHub (https://github.com/lucid-kv)"
template: &template |-4

██╗ ██╗ ██╗ ██████╗██╗██████╗ ██╗ ██╗██╗ ██╗
Expand All @@ -9,7 +9,7 @@ template: &template |-4
╚═════╝ ╚═════╝ ╚═════╝╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═══╝

A Fast, Secure and Distributed KV store with an HTTP API.
Written in Rust by Clint.Network (https://github.com/lucid-kv)
Written in Rust, Fork us on GitHub (https://github.com/lucid-kv)

{all-args}
settings:
Expand Down
14 changes: 13 additions & 1 deletion src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ impl Default for Configuration {
use_ssl: true,
ssl_certificate: String::new(),
ssl_certificate_key: String::new(),
show_banner: true
},
authentication: Authentication {
enabled: true,
enabled: false,
root_token: String::new(),
secret_key: String::new(),
},
Expand All @@ -58,6 +59,7 @@ impl Default for Configuration {
},
logging: Logging {
level: LevelFilter::Info,
outputs: vec![LogOutput::Stdout { colored: false }],
},
}
}
Expand All @@ -71,6 +73,7 @@ pub struct General {
pub use_ssl: bool,
pub ssl_certificate: String,
pub ssl_certificate_key: String,
pub show_banner: bool
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -111,6 +114,15 @@ pub struct Http {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Logging {
pub level: LevelFilter,
pub outputs: Vec<LogOutput>,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "lowercase", tag = "type")]
pub enum LogOutput {
File { path: PathBuf },
Stdout { colored: bool },
Stderr { colored: bool },
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
28 changes: 25 additions & 3 deletions src/kvstore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,20 @@ impl KvStore {
}
match &mut self.container.get_mut(&key) {
Some(kv_element) => {
kv_element.data = value;
kv_element.mime_type = mime_type;
if !kv_element.locked {
let mime_type = tree_magic::from_u8(value.as_ref());
kv_element.data = value;
kv_element.mime_type = mime_type;
}
kv_element.updated_at = Utc::now();
kv_element.update_count = kv_element.update_count + 1;
Some(kv_element.to_owned())
}
None => {
let mime_type = tree_magic::from_u8(value.as_ref());
let kv_element = KvElement {
data: value,
mime_type: mime_type,
mime_type,
created_at: Utc::now(),
updated_at: Utc::now(),
expire_at: Utc::now(),
Expand Down Expand Up @@ -102,6 +106,24 @@ impl KvStore {
}
}

pub fn increment_or_decrement(&self, key: String, value: f64) -> bool {
match &mut self.container.get_mut(&key) {
Some(kv_element) => {
let byte_to_string = String::from_utf8(kv_element.clone().data).unwrap(); // TODO: handle convert to string error
match byte_to_string.trim().parse::<f64>() {
Ok(initial_value) => {
kv_element.data = (initial_value + value).to_string().into_bytes();
kv_element.updated_at = Utc::now();
kv_element.update_count = kv_element.update_count + 1;
true
}
Err(_) => false,
}
}
None => false,
}
}

// TODO: implement Lock, Unlock, Increment, Decrement, Expire

pub fn drop(&self, key: String) {
Expand Down
Loading

0 comments on commit e0766a3

Please sign in to comment.