/kv-store-go

A simple key value store microservice

Primary LanguageGo

Key Value Store

License: MIT

A Microservice for Key-Value Storage

Features

  • Multi Tenancy
  • Authorization
  • REST API

Prerequisites

Go (version 1.21 or higher)

Installation

  1. Clone this repository:

    git clone https://github.com/conceptcodes/kv-store-go.git
    cd kv-store-go

Usage (Api)

  1. Run the server
gow run cmd/server/main.go
  1. Verify that the service is running
curl http://localhost:8080/health/alive
{
  "message": "Service is alive",
  "data": null,
  "error_code": ""
}
  1. 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": ""
}
  1. 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": ""
}
  1. 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": ""
}

Roadmap

  • CLI wrapper over the api
  • Add known errors to the api
  • Standard Log Formatting (with log levels)