Skip to content

Client/Server wrapper for BuntDB storage based on gRPC

License

Notifications You must be signed in to change notification settings

biobdeveloper/protobunt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ProtoBunt

Go

Server and client for BuntDB using gRPC over binary Protocol Buffers on top of simple TCP.

BuntDB is awesome simple key/value storage written on Go. It can be used locally, but there is not out-of-box way to use remote database connection. ProtoBunt claims to be the solution.

Install

$ go get -u github.com/biobdeveloper/protobunt

Usage

Start BundDb Server

package main

import "github.com/tidwall/buntdb"
import "github.com/biobdeveloper/protobunt"


func main() {
	// First, open some database...
	db, _ := buntdb.Open("dbname.db")
	
	// ...Then start the server
	host := "127.0.0.1"
	port := "8080"
	StartBuntServer(host, port, db)
	
}

Setup BundDb Client

package main

import "fmt"
import "github.com/biobdeveloper/protobunt"
import pb "protobunt/proto"


func main()  {
	
	// When the client is created, it makes the first test connection 
	// to negotiate the library version with the remote server
	cli, ctx, cancel := CreateBuntClient("127.0.0.1", "8080")
	defer cancel()

	// Create some record by pass key, value args
	req1 := pb.UpdateRequest{Key: "Alice", Value: "Bob", Action: SET}
	cli.Update(ctx, &req1)

	req2 := pb.ViewRequest{Key: "Alice", Action: GET}
	initValue, _ := cli.View(ctx, &req2)
	res2 := initValue.GetVal()

	fmt.Printf("Alice loves %s", res2)
	// Alice loves Bob
}

Warning

ProtoBundDB is currenty alpha version!

About

Client/Server wrapper for BuntDB storage based on gRPC

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages