vtec

module
v0.0.0-...-cdae8e3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 18, 2021 License: MIT

README

vtec

vtec, is a simple in-memory key-value store application.

vtec provides persistence by appending transactions to a json file and restoring data from the json file on startup.

vtec is designed with simplicity as the main purpose and has zero external dependencies.

VTEC Key-Value Store

To start using vtec, install Go and run go get:

$ go get -u github.com/ahmettek/vtec

App Usage

  • Locally:
go run cmd/api/main.go  
  • Docker:
docker build --tag vtec .   
docker run -p 5005:80 vtec
  • End Points:
[POST] http://localhost:5005/api/values
{
  "Key": "test",
  "Value":"value"
}
[GET] http://localhost:5005/api/values/:key
[DELETE] http://localhost:5005/api/values

OR

Postman Collection: https://raw.githubusercontent.com/ahmettek/vtec/main/static/endpoints.postman_collection.json

Package Usage

Vtec Key-Value Store

Create a store, add key and play with it.

v := vtec.New(vtec.Options{
    SyncInternal: 10000, //ms
    Storage: &storage.FileStore{
        FileName: "keyvalue-store.json",
    },
})

v.Set("my_string", "Hello World!");

value := v.Get("my_string")

fmt.Println(value) // Hello World!

Gopi Basic http Handler Wrapper

Create a api, add end point and serve!

  • Create Api:
api :=gopi.New()
  • Add End Point:
api.GET("/api/values/:id",func (g*GopiContext){})
api.POST("/api/values",func (g*GopiContext){})
api.DELETE("/api/values/",func (g*GopiContext){})
  • Handle Params:
func (v * ValuesHandler)  Get(gc * gopi.GopiContext) {
    id:= gc.Param[":id"]
}
  • Run:
 api.Listen("80")

Directories

Path Synopsis
cmd
api
pkg
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL