This is a simple key-value store executor implementation for testing Evolve nodes.
The HTTP server starts when the Evolve node starts and is automatically shut down when the node stops (including when receiving CTRL+C or other termination signals). The server is context-aware, meaning:
- It gracefully handles in-progress requests during shutdown
- It automatically shuts down when the node's context is cancelled
- There's a 5-second timeout for shutdown to complete
The HTTP server provides the following endpoints:
-
POST /tx: Submit a transaction to the KV executor.- Request body should contain the transaction data.
- For consistency with the KV executor's transaction format, it's recommended to use transactions in the format
key=value. - Returns HTTP 202 (Accepted) if the transaction is accepted.
-
GET /kv?key=<key>: Get the value for a specific key.- Returns the value as plain text if the key exists.
- Returns HTTP 404 if the key doesn't exist.
-
POST /kv: Set a key-value pair directly.- Request body should be a JSON object with
keyandvaluefields. - Example:
{"key": "mykey", "value": "myvalue"}
- Request body should be a JSON object with
-
GET /store: Get all key-value pairs in the store.- Returns a JSON object with all key-value pairs.
The KV executor expects transactions in the format key=value. For example:
mykey=myvaluefoo=bar
When a transaction is executed, the key-value pair is added to the store.