Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ozanturksever/natskv
https://github.com/ozanturksever/natskv
Last synced: about 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ozanturksever/natskv
- Owner: ozanturksever
- License: apache-2.0
- Created: 2024-02-22T16:51:57.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-04-16T19:28:14.000Z (8 months ago)
- Last Synced: 2024-06-21T14:31:00.255Z (6 months ago)
- Language: Go
- Size: 1.08 MB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Valkeyrie NatsKV
[![GoDoc](https://godoc.org/github.com/ozanturksever/natskv?status.png)](https://godoc.org/github.com/ozanturksever/natskv)
[![Build Status](https://github.com/ozanturksever/natskv/actions/workflows/build.yml/badge.svg)](https://github.com/ozanturksever/natskv/actions/workflows/build.yml)[`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 | NatsKV |
|-----------------------|:-----:|
| Put | 🟢️ |
| Get | 🟢️ |
| Delete | 🟢️ |
| Exists | 🟢️ |
| Watch | 🟢️ |
| WatchTree | 🟢️ |
| NewLock (Lock/Unlock) | ️ |
| List | 🟢️ |
| DeleteTree | 🟢️ |
| AtomicPut | 🟢️ |
| AtomicDelete | 🟢️ |## Supported Versions
nats-server versions >= `2.10`.
## Examples
```go
package mainimport (
"context"
"log""github.com/kvtools/valkeyrie"
"github.com/ozanturksever/natskv"
)func main() {
ctx := context.Background()config := &natskv.Config{
Bucket: "example",
EncodeKey: false,
}kv, err := valkeyrie.NewStore(ctx, natskv.StoreName, []string{ "nats://localhost:4222"}, 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)
}
}
```