Skip to content

EPAM, Introduction to Python and Golang, 2018. Golang task.

Notifications You must be signed in to change notification settings

siarhiejkresik/go-kvdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-kvdb

Go implementation of the server-client solution for storing key-value data (task link).

Requirements

  • make
  • docker
    Note: in order to run docker commands in the makefile targets without sudo you have to follow the next guide.

Getting source files

If you have go tool installed:

  • get source files: go get github.com/siarhiejkresik/go-kvdb
  • cd $GOPATH/src/github.com/siarhiejkresik/go-kvdb

Or get source files by cloning repository directly:

  • get source files: git clone https://github.com/siarhiejkresik/go-kvdb.git
  • cd go-kvdb

Building

Run make. This builds the go-kvdb docker container with the server and client binaries.

Running

Run server in a docker container:

  • make run [ARGS="<args>"] or
  • docker run --rm -p 9090:9090 go-kvdb:latest [ARG...]

Run client in a docker container:

  • make run-client [ARGS="<args>"] or
  • docker run --rm -it --entrypoint /app/client go-kvdb:latest [ARG...]

Other make targets

  • make check—runs code linting and verification
  • make test—runs tests for the project files
  • make coverage—measures test coverage, saves result to the coverage.out file

Server

Starting options:

  • -m, --mode The possible storage option (disk—stores database to disk, memory—database runs only in memory)
  • -p, --port The port for listening on (default—9090)
  • -v, --verbose Verbose mode, full log of the client requests

Client

Starting options:

  • -p, --port The port to connect to the server (default—9090)
  • -h, --host The host to connect to the server (default—127.0.0.1)

Supported commands

  • SET - updates a key at a time with the given value
  • GET - returns the value of a key
  • DEL - removes a key
  • KEYS - returns all keys matching pattern; pattern could include '*' symbol which matches zero or more characters
  • DUMP - (optional) - returns database data in the json format

References

  1. https://systembash.com/a-simple-go-tcp-server-and-tcp-client/
  2. https://www.oreilly.com/ideas/building-messaging-in-go-network-clients
  3. https://medium.com/@kpbird/golang-serialize-struct-using-gob-part-1-e927a6547c00

About

EPAM, Introduction to Python and Golang, 2018. Golang task.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published