This is a Go-based key-value store HTTP API service that allows you to set, retrieve, and search for key-value pairs. It also includes Prometheus monitoring for latency, HTTP status codes, and the total number of keys in the database.
- Prerequisites
- Getting Started
- Build and Push Docker Image
- Deploy on Minikube
- Usage
- Set a Key-Value Pair
- Get the Value for a Key
- Search for Keys
- Monitoring with Prometheus
- Contributing
- Go
- Docker
- Minikube
-
Clone this repository:
git clone git@github.com:TirushV/tempDB.git cd tempDB
-
Build your Docker image:
docker build -t <image-name>:latest
-
Deploy the Kubernetes resources:
kubectl apply -f deployment.yaml kubectl apply -f service.yaml kubectl apply -f ingress.yaml
-
Map your domain to Minikube's IP in /etc/hosts: (If testing from local)
echo "$(ip) your-domain.com" | sudo tee -a /etc/hosts
-
Access your application at http://localhost:8080.
To set a key-value pair, make a POST request to /key/set with a JSON payload:
{
"key": "your-key",
"value": "your-value"
}
curl -X POST http://localhost:8080/key/set -H "Content-Type: application/json" -d '{
"key": "your-key",
"value": "your-value"
}'
To retrieve the value for a key, make a GET request to /get/your-key. The value will be returned as a plain string.
curl http://localhost:8080/get/<key>
You can search for keys using the /search endpoint with the prefix and suffix query parameters:
- /search?prefix=your-prefix returns keys with the specified prefix.
- /search?suffix=your-suffix returns keys with the specified suffix.
curl "http://localhost:8080/search?prefix=abc"
curl "http://localhost:8080/search?suffix=-1"
This service includes Prometheus monitoring for latency, HTTP status codes, and the total number of keys in the database. You can access the Prometheus dashboard at http://localhost:8080/metrics.
** Metrics to watch for
- total_keys_in_db
- http_status_codes_total
- http_request_duration_seconds
Contributing Contributions are welcome! Please read the Contributing Guidelines for details.
License This project is licensed under the MIT License - see the LICENSE file for details.
Feel free to customize this README with specific installation, configuration, and usage details relevant to your project. Additionally, you may want to include information about API documentation, testing procedures, and any other relevant project-specific details.