modulepackage
0.1.17
Repository: https://github.com/spetzold/kvtools-dynamodb.git
Documentation: pkg.go.dev
# README
Valkeyrie DynamoDB
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 interface.
Calls | DynamoDB |
---|---|
Put | 🟢️ |
Get | 🟢️ |
Delete | 🟢️ |
Exists | 🟢️ |
Watch | 🔴 |
WatchTree | 🔴 |
NewLock (Lock/Unlock) | 🟢️ |
List | 🟢️ |
DeleteTree | 🟢️ |
AtomicPut | 🟢️ |
AtomicDelete | 🟢️ |
Examples
package main
import (
"context"
"log"
"github.com/kvtools/dynamodb"
"github.com/kvtools/valkeyrie"
)
func main() {
ctx := context.Background()
config := &dynamodb.Config{
Bucket: "example",
}
kv, err := valkeyrie.NewStore(ctx, dynamodb.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)
}
err = kv.Delete(ctx, key)
if err != nil {
log.Fatalf("Error trying to delete key %v", key)
}
log.Printf("value: %s", string(pair.Value))
}
# Functions
New creates a new AWS DynamoDB client.
# Constants
DefaultReadCapacityUnits default read capacity used to create table.
DefaultWriteCapacityUnits default write capacity used to create table.
DeleteTreeTimeoutSeconds the maximum time we retry a write batch.
StoreName the name of the store.
# Variables
ErrBucketOptionMissing is returned when bucket config option is missing.
ErrDeleteTreeTimeout delete batch timed out.
ErrLockAcquireCancelled stop called before lock was acquired.
ErrMultipleEndpointsUnsupported is returned when more than one endpoint is provided.