Simple Cache Go microservice
This is a simple Microservice which will provide top commodity (Iron, Gold, Platinium and silver).
Gorilla is used as web toolkit, It makes use of go-cache to store the data in cache-memory,
scribble is used as database, Any update in the database Apache Kafaka will notify so that cache will be updated automatically.
Packages
- gorilla : A Web Toolkit.
- Sarama : Go client library for Apache Kafka.
- scribble : A tiny JSON database in Golang.
- go-cache : An in-memory key:value store.
- Swagger : An API documentation toolkit
Usage
git clone https://github.com/akshayvijapur/Go_sample_microservice.git
cd Go_sample_microservice/
- perform docker compose up
docker-compose up -d
- Initialize the Cache by calling to InitializeCommand REST API
curl -X POST http://localhost:3000/api/v1/InitializeCommodity
curl http://localhost:3000/api/v1/GetCommodity
- As DB is being updated with new Commodity data after every 10 seconds, Kafka will notify the receiver
which in turns will update the cache.