update documentation with info about RPC server

This commit is contained in:
Maxime Van Hees
2025-09-10 11:59:31 +02:00
parent 271c6cb0ae
commit 764fcb68fa
2 changed files with 101 additions and 0 deletions

View File

@@ -24,6 +24,12 @@ cargo build --release
./target/release/herodb --dir /path/to/db --port 6379
```
## RPC Server
HeroDB includes an optional JSON-RPC 2.0 management server for database administration tasks. Enable it with the `--enable-rpc` flag and specify the port with `--rpc-port` (default: 8080).
For a complete list of available RPC commands and usage examples, see [RPC_COMMANDS.md](RPC_COMMANDS.md).
### Options
- `--dir`: Database directory (required)
@@ -31,6 +37,8 @@ cargo build --release
- `--debug`: Enable debug logging
- `--encrypt`: Enable database encryption
- `--encryption-key`: Master encryption key for encrypted databases
- `--enable-rpc`: Enable RPC management server
- `--rpc-port`: RPC server port (default: 8080)
### Examples

93
RPC_COMMANDS.md Normal file
View File

@@ -0,0 +1,93 @@
# HeroDB RPC Commands
HeroDB provides a JSON-RPC 2.0 interface for database management operations. The RPC server runs on a separate port (default 8080) and can be enabled with the `--enable-rpc` flag.
All RPC methods are prefixed with the namespace `herodb`.
## Available Commands
### herodb_listDatabases
Lists all database indices that exist.
**Example:**
```bash
curl -X POST http://localhost:8080 \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "herodb_listDatabases", "id": 1}'
```
### herodb_createDatabase
Creates a new database at the specified index.
**Parameters:**
- `db_index` (number): Database index to create
**Example:**
```bash
curl -X POST http://localhost:8080 \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "herodb_createDatabase", "params": [1], "id": 1}'
```
### herodb_getDatabaseInfo
Retrieves detailed information about a specific database.
**Parameters:**
- `db_index` (number): Database index
**Example:**
```bash
curl -X POST http://localhost:8080 \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "herodb_getDatabaseInfo", "params": [0], "id": 1}'
```
### herodb_configureDatabase
Configures an existing database with specific settings.
**Parameters:**
- `db_index` (number): Database index
- `config` (object): Configuration object
**Example:**
```bash
curl -X POST http://localhost:8080 \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "herodb_configureDatabase", "params": [0, {"name": "test", "max_size": 1048576}], "id": 1}'
```
### herodb_setDatabaseEncryption
Sets encryption for a specific database index.
**Parameters:**
- `db_index` (number): Database index
- `encryption_key` (string): Encryption key
**Example:**
```bash
curl -X POST http://localhost:8080 \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "herodb_setDatabaseEncryption", "params": [10, "my-secret-key"], "id": 1}'
```
### herodb_deleteDatabase
Deletes a database and its files.
**Parameters:**
- `db_index` (number): Database index to delete
**Example:**
```bash
curl -X POST http://localhost:8080 \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "herodb_deleteDatabase", "params": [1], "id": 1}'
```
### herodb_getServerStats
Retrieves server statistics.
**Example:**
```bash
curl -X POST http://localhost:8080 \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "herodb_getServerStats", "id": 1}'