https://github.com/kvtools/etcdv3
Valkeyrie: etcdv3
https://github.com/kvtools/etcdv3
etcd etcdv3 go golang kv-store valkeyrie
Last synced: 23 days ago
JSON representation
Valkeyrie: etcdv3
- Host: GitHub
- URL: https://github.com/kvtools/etcdv3
- Owner: kvtools
- License: apache-2.0
- Created: 2022-09-07T16:25:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-30T01:18:55.000Z (11 months ago)
- Last Synced: 2024-07-01T20:41:18.694Z (11 months ago)
- Topics: etcd, etcdv3, go, golang, kv-store, valkeyrie
- Language: Go
- Homepage:
- Size: 164 KB
- Stars: 2
- Watchers: 2
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Valkeyrie etcd v3
[](https://godoc.org/github.com/kvtools/etcdv3)
[](https://github.com/kvtools/etcdv3/actions/workflows/build.yml)
[](https://goreportcard.com/report/github.com/kvtools/etcdv3)[`valkeyrie`](https://github.com/kvtools/valkeyrie) provides a Go native library to store metadata using Distributed Key/Value stores (or common databases).
## 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 | Etcd |
|-----------------------|:----:|
| Put | 🟢️ |
| Get | 🟢️ |
| Delete | 🟢️ |
| Exists | 🟢️ |
| Watch | 🟢️ |
| WatchTree | 🟢️ |
| NewLock (Lock/Unlock) | 🟢️ |
| List | 🟢️ |
| DeleteTree | 🟢️ |
| AtomicPut | 🟢️ |
| AtomicDelete | 🟢️ |## Supported Versions
Etcd version >= `3.0` with **APIv3**
## Examples
```go
package mainimport (
"context"
"log""github.com/kvtools/etcdv3"
"github.com/kvtools/valkeyrie"
)func main() {
ctx := context.Background()config := &etcdv3.Config{
Password: "example",
}kv, err := valkeyrie.NewStore(ctx, etcdv3.StoreName, []string{"localhost:8500"}, config)
if err != nil {
log.Fatal("Cannot create store")
}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)
}
}
```