/kvstore

Training material, in-memory key/value store example

Primary LanguageGoOtherNOASSERTION

Version Golang Tests Golang CI Lint codecov Powered by Rake

KVStore

Simple in-memory key/value store for training purpose. Project demonstrates basic DDD approach (storage/service/http layer logic)


Usage

To run server locally;

rake

or cd to project root;

go run cmd/server/main.go

Endpoints:

GET    /healthz/live/
GET    /healthz/ready/

POST   /api/v1/set/
GET    /api/v1/get/?key={key}
PUT    /api/v1/update/
DELETE /api/v1/delete/?key={key}
GET    /api/v1/list/

Also, you can use postman collection.


Development

Requirements

  • go1.21.0
  • bumpversion
  • pre-commit

You can create .env file inside of the project root for environment variables

Environment variables information:

Variable Name Description Default Value
SERVER_ENV Server environment information for run-time local
LOG_LEVEL Logging level INFO

Install pre-commit

https://pre-commit.com/

$ cd /path/to/kvstore
$ pre-commit install       # do only once!

Available tasks:

$ rake -T

rake default                        # default task
rake docker:build                   # Build image (locally)
rake docker:run                     # Run image (locally)
rake lint                           # run golangci lint
rake release[revision]              # release new version major,minor,patch, default: patch
rake run:server                     # run server
rake test:run_all                   # run all tests
rake test:run_all_display_coverage  # run all tests and display coverage

Run all tests via;

rake test:run_all
rake test:run_all_display_coverage  # macos only!

Docker

# build
rake docker:build

# run
rake docker:run