Skip to content

treyburn/lockbox

Repository files navigation

Lockbox

codecov

A simple, distributed key-value store.

Usage

Stand up the service using:

docker compose up -d api

Then you can hit it with curl:

# add a key
curl -X PUT -d 'testing' https://localhost:443/v1/abc --insecure

# get the value for a key
curl -X GET https://localhost:443/v1/abc --insecure

# delete a key
curl -X DELETE https://localhost:443/v1/abc --insecure

API

http

grpc

Setup

Below will contain the required tooling and common commands for developing on this codebase.

Prerequisites

  1. Install the Go toolchain with a version of at least the value specified in the go.mod.
  2. Install docker engine and docker compose. The easiest way to handle this is via docker desktop.
  3. Install golangci-lint for local linting and formatting.

Common commands

Use the following to run tests:

go test -race ./...

Use the following for code formatting:

golangci-lint fmt

Use the following for code linting:

golangci-lint run

Local dev delopyments

Build containers by running:

docker compose build

Pull down updated containers with:

docker compose pull

Stand up the development deployment with:

docker compose up -d api

Tear down the docker environment with:

docker compose down

TODO

Various items for cleanup.

Project

  • Improve README
    • Create a TODO section
    • Provide a thorough project description
    • Provide useful code snippets for cli execution
    • Document the API(s)
    • Document prerequisites and general dev setup
  • Set up CI
    • Linting w/ golangci-lint
    • Testing
    • Report test coverage in PR and on project README
    • Build docker container
  • Bring in Just for encapsulating typical project commands

Service

  • Update Go + Deps
  • Utilize multi-stage docker build
  • Swap over to Postgres logger by default
  • Restructure main for better configurability
    • Add in env var/cli configuration setting
    • Reconsider defaults
  • Improve unit and integration testing
  • Refactor to use standard Go project layouts
  • Drop gorilla/mux for chi (https://github.com/go-chi/chi)
  • Drop lib/pq for pgx (https://github.com/jackc/pgx)
  • Improve logging and utilize context logging
  • Swap over to sqlc instead of raw SQL (https://github.com/sqlc-dev/sqlc)
  • Create an OpenAPI specification w/ validation
  • Add a gRPC API
  • Instrument for OpenTelemetry
    • Utilize decorator patterns
    • Utilize telemetry middleware
  • Add healthz endpoints for service health checking

Deployment

  • Generate a valid cert via LetsEncrypt
  • Utilize mtls termination between traefik and api services
  • Enable SSL with Postgres
  • Set up OpenTelemetry collectors + Grafana
  • Utilize healthcheck endpoints

About

A simple, distributed key-value store

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published