A Microservice for Key-Value Storage
- Multi Tenancy
- Authorization
- REST API
-
Clone this repository:
git clone https://github.com/conceptcodes/kv-store-go.git cd kv-store-go
- Run the server
gow run cmd/server/main.go
- Verify that the service is running
curl http://localhost:8080/health/alive
{
"message": "Service is alive",
"data": null,
"error_code": ""
}
- Onboard a new tenant. This action will add an authorization header to the response. Utilize this header for all subsequent requests.
curl --location 'http://localhost:8080/api/tenant/onboard'
{
"message": "Tenant onboarded successfully",
"data": {
"tenant_id": "sample_tenant_id",
"tenant_secret": "sample_tenant_secret"
},
"error_code": ""
}
- Create a new key-value pair
curl --location 'http://localhost:8080/api/records' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <sample_auth_token>' \
--data '{
"key": "long",
"value": "word",
"ttl": 3600
}'
{
"message": "Record created successfully",
"data": {
"key": "long",
"value": "word",
},
"error_code": ""
}
- Get a key-value pair
curl --location 'http://localhost:8080/api/records/long' \
--header 'Authorization: Bearer <sample_auth_token>'
{
"message": "Record Found Successfully",
"data": {
"key": "long",
"value": "world"
},
"error_code": ""
}
- CLI wrapper over the api
- Add known errors to the api
- Standard Log Formatting (with log levels)