Skip to content

Commit

Permalink
Engine service (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
maxmielchen authored Jan 21, 2024
1 parent fc0f02c commit 608b08e
Show file tree
Hide file tree
Showing 12 changed files with 331 additions and 240 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "varia-db"
version = "0.0.2"
version = "0.0.3"
edition = "2021"

[dependencies]
Expand Down
38 changes: 33 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@ A key feature of VariaDB is that it is not designed to be used behind a server a

## How to use VariaDB?

Quick Start:
VariaDB is shipped as a Docker image. You can pull the image from the GitHub Container Registry. The image is executable on linux/amd64 and linux/arm64.

#### Quick Start

```bash
docker pull ghcr.io/maxmielchen/varia-db:latest
docker run -p 8654:8654 ghcr.io/maxmielchen/varia-db:latest
```

Environment Variables:
#### Environment Variables

| Variable | Default | Description |
| --- | --- | --- |
Expand All @@ -38,14 +40,16 @@ Environment Variables:

## Protocol

VariaDB can store key-value pairs. The key is a string, and the value is a typed.
A value can be a string, a number, a boolean, or a list of values, or a map of values.
VariaDB can store key-value pairs. The key is a string, and the value is a typed value.
A value can be a string, a number, a boolean, or a list of values, or a map of values. In the some cases, the value is packet in a Respond object.
[OpenAPI Documentation](openapi.yaml)

#### Values Examples

```json
{"Text": "Hello, world!"}
{
"Text": "Hello, world!"
}
```

```json
Expand All @@ -68,8 +72,32 @@ A value can be a string, a number, a boolean, or a list of values, or a map of v
}
```

#### Respond Examples

```json
{
"Value": {"Text": "Hello, world!"}
}
```

```json
{
"Array": [ "key1", "key2", "key3" ]
}
```

#### Operations

| Operation | HTTP | Type | Respond | Description |
| --- | --- | --- | --- | --- |
| `PUT` | `PUT /put/{key}` | `Respond::Value` | `{ "Value": null }` | Stores a value under a key and returns the old value. |
| `GET` | `GET /get/{key}` | `Respond::Value` | `{ "Value": { "Text": "Hello, world!" } }` | Returns the value stored under a key. |
| `DEL` | `DELETE /del/{key}` | `Respond::Value` | `{ "Value": { "Text": "Hello, world!" } }` | Deletes the value stored under a key and returns the old value. |
| `LIST` | `GET /list` | `Respond::Array` | `{ "Array": [ "key1", "key2", "key3" ] }` | Returns a list of all keys.


#### cURL Examples

Put:
```curl
curl -X 'PUT' \
Expand Down
65 changes: 32 additions & 33 deletions openapi.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
openapi: "3.0.0"

openapi: 3.0.0
info:
title: VariaDB
version: 0.0.2

version: 0.0.3
servers:
- url: http://localhost:8654

- url: '{scheme}://{host}:{port}'
variables:
scheme:
default: http
enum:
- https
- http
description: 'Scheme'
host:
default: localhost
description: 'Host'
port:
default: '8654'
description: 'Port'
description: Default

paths:
/put/{key}:
put:
Expand All @@ -29,11 +42,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Value'
'400':
description: Bad Request
'500':
description: Internal Server Error
$ref: '#/components/schemas/Respond'

/get/{key}:
get:
Expand All @@ -50,12 +59,8 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Value'
'400':
description: Bad Request
'500':
description: Internal Server Error

$ref: '#/components/schemas/Respond'

/del/{key}:
delete:
summary: Delete a value
Expand All @@ -71,11 +76,7 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/Value'
'400':
description: Bad Request
'500':
description: Internal Server Error
$ref: '#/components/schemas/Respond'

/list:
get:
Expand All @@ -86,48 +87,46 @@ paths:
content:
application/json:
schema:
type: array
items:
type: string
'500':
description: Internal Server Error
$ref: '#/components/schemas/Respond'

components:
schemas:
Respond:
oneOf:
- $ref: '#/components/schemas/Value'
- type: array
items:
type: string
Value:
nullable: true
oneOf:
- $ref: '#/components/schemas/TextValue'
- $ref: '#/components/schemas/NumberValue'
- $ref: '#/components/schemas/BooleanValue'
- $ref: '#/components/schemas/ArrayValue'
- $ref: '#/components/schemas/MapValue'

TextValue:
type: object
properties:
Text:
type: string

NumberValue:
type: object
properties:
Number:
type: integer

BooleanValue:
type: object
properties:
Boolean:
type: boolean

ArrayValue:
type: object
properties:
Array:
type: array
items:
$ref: '#/components/schemas/Value'

MapValue:
type: object
properties:
Expand All @@ -139,4 +138,4 @@ components:
key:
type: string
value:
$ref: '#/components/schemas/Value'
$ref: '#/components/schemas/Value'
Loading

0 comments on commit 608b08e

Please sign in to comment.