dynastorev2

This package provides a CRUD (create, read, update and delete) store for AWS DynamoDB using the AWS Go SDK v2.

GitHub Actions status Go Report Card Documentation

Overview

This is a rewrite of the original dynastore with the main differences being:

  1. It uses the Generics feature added in Go 1.18
  2. It is built on AWS Go SDK v2.
  3. The API has been simplified.

Example

	ctx := context.Background()

	cfg, err := config.LoadDefaultConfig(ctx)
	if err != nil {
		// handle error
	}

	client = dynamodb.NewFromConfig(cfg)
	store := dynastorev2.New[string, string, []byte](client, "tickets-table")

	res, err := store.Create(ctx, "customer", "01FCFSDXQ8EYFCNMEA7C2WJG74", []byte(`{"name": "Stax"}`))
	if err != nil {
		// handle error
	}

	// print out the version from the mutation result, this is used for optimistic locking
	fmt.Println("version", res.Version)

Status

  • Added CRUD with conditional checks and tests
  • List with pagination
  • Optimistic Locking for Updates
  • Locking
  • Leasing

References

Prior work in this space:

Updates to the original API are based on a great blog post by @davecheney https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis

License

This code was authored by Mark Wolfe and licensed under the Apache 2.0 license.

GitHub

View Github