Skip to content

Commit

Permalink
added readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dejankos committed Sep 1, 2020
1 parent afa7e2a commit eee4b3f
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name = "rocky"
version = "0.1.0"
authors = ["dkos <kosdejan@yahoo.com>"]
edition = "2018"
categories = ["http", "rocksdb"]
categories = ["http", "rocksdb", "storage"]
description = "RocksDb as a service"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
70 changes: 63 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,72 @@
# Rocky
Rocky is a http service based on RocksDb with support for multiple databases and expiration.
Written in Rust on top of actix-web.
Rocky is a key/value storage service based on facebook [RocksDb](https://github.com/facebook/rocksdb/wiki) with support for multiple databases and record expiration.


## Rocky REST API
### Open db

You can open a new db with a ```POST``` request on ```SERVICE_URL:SERVICE_PORT/{db_name}```

## Open db
```curl -X POST localhost:8080/database_1```

## Close db
A successful request is indicated by a ```200 OK HTTP``` status code.
Each database is created with the same [configuration](#Configuration).

### Close db
You can close an existing db with a ```DELETE``` request on ```SERVICE_URL:SERVICE_PORT/{db_name}```

```curl -X DELETE localhost:8080/database_1```

A successful request is indicated by a ```200 OK HTTP``` status code.

### Store record
You can write data with a ```POST``` request on ```SERVICE_URL:SERVICE_PORT/{db_name}/{key}```

```curl -d 'payload can be anything' localhost:8080/database_1/record_1```

A successful request is indicated by a ```200 OK HTTP``` status code.

## Store record
#### TTL support
## Read record
## Delete record
Rocky support time to live per record provided in milliseconds.
You can add ```ttl``` on record by providing a custom header

```curl -d 'I\'ll expire soon' -H 'ttl: 5000' localhost:8080/database_1/expiring_record_1```

### Read record
You can read data with a ```GET``` request on ```SERVICE_URL:SERVICE_PORT/{db_name}/{key}```

```curl -v localhost:8080/database_1/record_1```

The response contains data associated with the database and and key provided in path:

From the previous example this is our response
```payload can be anything⏎ ```

Data is always return with content type header ```content-type: application/octet-stream```
A successful request is indicated by a ```200 OK HTTP``` status code.

### Delete record
You can delete data with a ```DELETE``` request on ```SERVICE_URL:SERVICE_PORT/{db_name}/{key}```

```curl -X DELETE localhost:8080/database_1/record_1```

A successful request is indicated by a ```200 OK HTTP``` status code.

### Metrics
Service metrics in [prometheus format](https://github.com/prometheus/docs/blob/master/content/docs/instrumenting/exposition_formats.md) are available for scraping under ```SERVICE_URL:SERVICE_PORT/metrics```

## Configuration

When running service external configuration and log path should be provided or Rocky will use defaults.
```--log_path``` path where log files should be written
```--config_path``` path where service should look for external database and service configuration. Rocky will look for db_config.toml
and service_config.toml files under this path if not found will create config files with defaults.

For database performance tuning check the official [RocksDb tuning guide](https://github.com/facebook/rocksdb/wiki/RocksDB-Tuning-Guide)
For service performance tuning check example service_config.toml and yes - ```workers``` is the only config parameter that matters, default is number of logical CPUs
Example configuration is provided under ```project_root/config```

## Licence
Rocky is licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0)


4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use actix_web::body::{Body, ResponseBody};
use actix_web::http::header::ContentType;
use actix_web::middleware::errhandlers::{ErrorHandlerResponse, ErrorHandlers};
use actix_web::web::Bytes;
use actix_web::{delete, dev, get, http, post, put, HttpRequest, HttpResponse, ResponseError};
use actix_web::{delete, dev, get, http, post, HttpRequest, HttpResponse, ResponseError};
use actix_web::{web, App, HttpServer};
use actix_web_prom::PrometheusMetrics;
use log::LevelFilter;
Expand Down Expand Up @@ -114,7 +114,7 @@ async fn close(db_name: web::Path<String>, db_man: web::Data<DbManager>) -> Resp
Ok(HttpResponse::Ok().finish())
}

#[put("/{db_name}/{key}")]
#[post("/{db_name}/{key}")]
async fn store(
p_val: web::Path<PathVal>,
body: Bytes,
Expand Down

0 comments on commit eee4b3f

Please sign in to comment.