Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kvtools/valkeyrie
Distributed Key/Value Store Abstraction Library written in Go.
https://github.com/kvtools/valkeyrie
boltdb consul dynamodb etcd go golang key-value kv-store libkv redis zookeeper
Last synced: 2 days ago
JSON representation
Distributed Key/Value Store Abstraction Library written in Go.
- Host: GitHub
- URL: https://github.com/kvtools/valkeyrie
- Owner: kvtools
- License: apache-2.0
- Created: 2017-11-13T09:32:49.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2024-06-30T01:29:57.000Z (4 months ago)
- Last Synced: 2024-08-02T20:46:25.564Z (3 months ago)
- Topics: boltdb, consul, dynamodb, etcd, go, golang, key-value, kv-store, libkv, redis, zookeeper
- Language: Go
- Homepage: https://pkg.go.dev/github.com/kvtools/valkeyrie
- Size: 670 KB
- Stars: 274
- Watchers: 11
- Forks: 43
- Open Issues: 3
-
Metadata Files:
- Readme: readme.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
- my-awesome - kvtools/valkeyrie - value,kv-store,libkv,redis,zookeeper pushed_at:2024-06 star:0.3k fork:0.0k Distributed Key/Value Store Abstraction Library written in Go. (Go)
README
Valkeyrie
Distributed Key/Value Store Abstraction Library
# Valkeyrie
[![Go Reference](https://pkg.go.dev/badge/github.com/kvtools/valkeyrie.svg)](https://pkg.go.dev/github.com/kvtools/valkeyrie)
[![Build and test](https://github.com/kvtools/valkeyrie/actions/workflows/build.yml/badge.svg)](https://github.com/kvtools/valkeyrie/actions/workflows/build.yml)
[![Go Report Card](https://goreportcard.com/badge/github.com/kvtools/valkeyrie)](https://goreportcard.com/report/github.com/kvtools/valkeyrie)`valkeyrie` provides a Go native library to store metadata using Distributed Key/Value stores (or common databases).
Its goal is to abstract common store operations (`Get`, `Put`, `List`, etc.) for multiple Key/Value store backends.
For example, you can easily implement a generic *Leader Election* algorithm on top of it (see the [docker/leadership](https://github.com/docker/leadership) repository).
The benefit of `valkeyrie` is not to duplicate the code for programs that should support multiple distributed Key/Value stores such as `Consul`/`etcd`/`zookeeper`, etc.
## Examples of Usage
You can refer to [Examples](https://github.com/kvtools/valkeyrie/blob/master/docs/examples.md) for a basic overview of the library.
```go
package mainimport (
"context"
"log"
"time""github.com/kvtools/consul"
"github.com/kvtools/valkeyrie"
)func main() {
ctx := context.Background()
config := &consul.Config{
ConnectionTimeout: 10 * time.Second,
}kv, err := valkeyrie.NewStore(ctx, consul.StoreName, []string{"localhost:8500"}, config)
if err != nil {
log.Fatal("Cannot create store consul")
}key := "foo"
err = kv.Put(ctx, key, []byte("bar"), nil)
if err != nil {
log.Fatalf("Error trying to put value at key: %v", key)
}pair, err := kv.Get(ctx, key, nil)
if err != nil {
log.Fatalf("Error trying accessing value at key: %v", key)
}log.Printf("value: %s", string(pair.Value))
err = kv.Delete(ctx, key)
if err != nil {
log.Fatalf("Error trying to delete key %v", key)
}
}
```## Compatibility
A **storage backend** in `valkeyrie` implements (fully or partially) the [Store](https://github.com/kvtools/valkeyrie/blob/master/store/store.go#L69) interface.
| Calls | Consul | Etcd | Zookeeper | Redis | BoltDB | DynamoDB |
|-----------------------|:------:|:----:|:---------:|:-----:|:------:|:--------:|
| Put | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ |
| Get | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ |
| Delete | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ |
| Exists | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ |
| Watch | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🔴 | 🔴 |
| WatchTree | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🔴 | 🔴 |
| NewLock (Lock/Unlock) | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🔴 | 🟢️ |
| List | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ |
| DeleteTree | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ |
| AtomicPut | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ |
| AtomicDelete | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ | 🟢️ |The store implementations:
- [boltdb](https://github.com/kvtools/boltdb)
- [consul](https://github.com/kvtools/consul)
- [dynamodb](https://github.com/kvtools/dynamodb)
- [etcdv2](https://github.com/kvtools/etcdv2)
- [etcdv3](https://github.com/kvtools/etcdv3)
- [redis](https://github.com/kvtools/redis)
- [zookeeper](https://github.com/kvtools/zookeeper)The store template:
- [template](https://github.com/kvtools/template)
## Limitations
Distributed Key/Value stores often have different concepts for managing and formatting keys and their associated values.
Even though `valkeyrie` tries to abstract those stores aiming for some consistency, in some cases it can't be applied easily.Calls like `WatchTree` may return different events (or number of events) depending on the backend
(for now, `Etcd` and `Consul` will likely return more events than `Zookeeper` that you should triage properly).## Contributing
Want to contribute to `valkeyrie`?
Take a look at the [Contribution Guidelines](https://github.com/kvtools/valkeyrie/blob/master/CONTRIBUTING.md).The [Maintainers](https://github.com/kvtools/valkeyrie/blob/master/maintainers.md).
## Copyright and License
Apache License Version 2.0
Valkeyrie started as a hard fork of the unmaintained [libkv](https://github.com/docker/libkv).