Package kvalbbolt
implements a bbolt binding for KVAL (Key Value Access
Language). The binding provides more than just 'boilerplate' for working with
bbolt. It implements a language thus enabling access at a higher abstraction.
Users of the binding can provide simple instructions and the binding will take
care of Bucket creation (and deletion), and the generation of keys and values,
plus their maintenance, no matter how deep into the database structure they are
needed, or indeed exist.
"Everything should be made as simple as possible, but no simpler." - Albert Einstein
The most up-to-date specification for KVAL can be found here: https://github.com/kval-access-language/kval
My first blog post describing my thoughts a little better can be found here: http://exponentialdecay.co.uk/blog/key-value-access-language-kval-for-boltdb-and-golang/
I have created a modest specification for a key value access language. It allows for input and access of values to a key value store such as Golang's bbolt.
The language specification: https://github.com/kval-access-language/KVAL
-
Single function entry-point:
res, err := Query(kb, "INS B1 >> B2 >> B3 >>>> KEY :: VAL") // Will create three buckets, plus k/v in one-go
res, err := Query(kb, "GET B1 >> B2 >> B3 >>>> KEY") // Will retrieve that entry in one-go
-
Start using bbolt immediately without writing boiler plate before you can code.
-
KVAL-Parse enables handling of Base64 encoded binary BLOBS.
-
Regular Expression based searching for key names and values/
-
KVAL Language specifies easy bulk or singleton DELETE (
DEL
) and RENAME (REN
) capabilities. -
It's a language specification so other bindings for other databases are possible.
Use of the kvalbbolt
binding is simple. There is one function which accepts a
string formatted to KVAL's specification:
res, err = Query(kb, "GET Bucket One >> Bucket Two >>>> Requested Key")
if err != nil {
fmt.Fprintf(os.Stderr, "Error querying db: %v", err)
} else {
//Access our result structure
res.Result // a map[string]string
}
For write operations we simply check for the existence of an error, else the operation passed as expected:
res, err = Query(kb, "INS Bucket One >> Bucket Two >>>> Insert Key :: Insert Value")
if err != nil {
fmt.Fprintf(os.Stderr, "Error querying db: %v", err)
}
Once you've a connection to a database, call Query(...)
as many times as you
like to work with your data. The most basic implementation, creating a DB, and
inserting data looks as follows:
package main
import (
"fmt"
"os"
kval "github.com/kval-access-language/kval-bbolt"
)
func main() {
kb, err := kval.Connect("newdb.bolt")
if err != nil {
fmt.Fprintf(os.Stderr, "Error opening bolt database: %#v", err)
os.Exit(1)
}
defer kval.Disconnect(kb)
//Lets do a test insert...
res, err := kval.Query(kb, "INS test bucket one >> test bucket two >>>> key one :: value one")
if err != nil {
//work with your error
}
// else: start working with you res struct
}
Have a look at some of the bits and pieces implemented as part of this binding in the demo Go application here: https://github.com/kval-access-language/kval-boltdb-demo
The following would be helpful:
- Comments on the KVAL specification, working towards a version 1.
- Code review
- Testers - Get using it and report your issues!
- Spread the word
- Let me know how it goes here via Issue, or on Twitter via @beet_keeper
GPL Version 3: https://github.com/kval-access-language/KVAL-BBolt/blob/master/LICENSE