https://github.com/pedro-gutierrez/cmdb
A simple KV store written in Go
https://github.com/pedro-gutierrez/cmdb
golang http lmdb rest s3
Last synced: 8 months ago
JSON representation
A simple KV store written in Go
- Host: GitHub
- URL: https://github.com/pedro-gutierrez/cmdb
- Owner: pedro-gutierrez
- Created: 2018-01-26T15:04:06.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-29T20:40:42.000Z (over 7 years ago)
- Last Synced: 2024-12-28T11:45:33.808Z (10 months ago)
- Topics: golang, http, lmdb, rest, s3
- Language: Go
- Size: 18.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CMDB
* Simple KV store
* JSON in, JSON out
* Written in Go
* LMDB backend.
* Backup/Restore to/from S3## Getting started
```
docker run
-e "AWS_ACCESS_KEY_ID=xxx" \
-e "AWS_ACCESS_KEY_ID=yyy" \
-e "AWS_REGION=zzz" \
-e "AWS_BUCKET=backups" \
-e "CMDB_MAP_SIZE=10737418240" \
-e "CMDB_NAME=countries" \
-e "CMDB_PORT=7801" \
-e "CMDB_DATA=/data" \
-v "/tmp/data:/data" \
-n cmdb \
-p 7801:7801 \
pedrogutierrez/cmdb:latest
```## Usage
Set a value for key:
```
$ curl -X POST http://localhost:7801/foo --data "1"
```Get a single value for a key:
```
$ curl http://localhost:7801/foo1
```Set multiple values for the same key
```
$ curl -X POST http://localhost:7801/foo --data "2"
$ curl -X POST http://localhost:7801/foo --data "3"
$ curl -X POST http://localhost:7801/foo --data "4"```
Get multiple values for the same key
```
$ curl http://localhost:7801/keys/foo?count=2[1,2]
``````
$ curl http://localhost:7801/keys/foo?count=2&skip=2[3,4]
```Unique keys:
```
$ curl -X POST -i http://localhost:7801/bar?unique=true --data "1"HTTP/1.1 200 OK
Date: Mon, 29 Jan 2018 18:43:29 GMT
Content-Length: 0
Content-Type: text/plain; charset=utf-8$ curl -X POST -i http://localhost:7801/bar?unique=true --data "2"
HTTP/1.1 409 Conflict
Date: Mon, 29 Jan 2018 18:44:09 GMT
Content-Length: 8
Content-Type: text/plain; charset=utf-8Conflict
```Do a backup to S3:
```
$ curl -X POST http://localhost:7801/backups/new{"name":"20180126174859","size":502}
```Restore a backup from S3:
```
$ curl -X POST http://localhost:7801/backups/20180126174859/restore{ "size": 502}
```