dynatomic

module
v0.0.0-...-e805d58 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 3, 2020 License: MIT

README

Dynatomic

Build Status Build status Go Report Card GoDoc Coverage Status MIT license CodeFactor Mentioned in Awesome Go

Dynatomic is a library for using dynamodb as an atomic counter

Motivation

The dynatomic was written to use dynamodb as a quick and easy atomic counter.

The package tries to serve two unique use cases:

  • Unique, fast real-time writes, e.g. user visits to a page or rate limiting
  • Large number of asynchronous writes that need to be eventually consistent, e.g. API usage by a client for billing

Usage

Basic usage:

// Initialize the dynatomic backround goroutine with a batch size of 100,
// a wait time of a second, an AWS config and a function that will
// notify the user of internal errors
d := New(100, time.Second, config, errHandler)
d.RowChan <- &types.Row{...}
d.RowChan <- &types.Row{...}
d.RowChan <- &types.Row{...}
...
d.Done()

Dynamo will update accordingly.

For example if you write the rows:

Table: MyTable, Key: A, Range: A, Incr: 5
Table: MyTable, Key: A, Range: A, Incr: 5
Table: MyTable, Key: A, Range: A, Incr: 5
Table: MyTable, Key: A, Range: A, Incr: 5

Then MyTable Key A, Range A will now show a value of 20

Development

To copy the repository run:

go get github.com/tylfin/dynatomic

Then you can run the full test suite by doing:

docker-compose run dynatomic

Contributing

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug
  2. Fork the repository on GitHub to start making your changes to the master branch (or branch off of it)
  3. Write a test which shows that the bug was fixed or that the feature works as expected
  4. Send a pull request and bug the maintainer until it gets merged and published

Directories

Path Synopsis
pkg
dynamo
Package dynamo wraps the AWS DynamoDB SDK To insert a row: svc, _ := dynamo.New(conf) row := &types.Row{...} count, err := dynamo.Insert(svc, row)
Package dynamo wraps the AWS DynamoDB SDK To insert a row: svc, _ := dynamo.New(conf) row := &types.Row{...} count, err := dynamo.Insert(svc, row)
dynatomic
Package dynatomic provides a convenient wrapper API around using DynamoDB as highly available, concurrent, and performant asynchronous atomic counter Basic usage: // Initialize the dynatomic backround goroutine with a batch size of 100, // a wait time of a second, an AWS config and a function that will // notify the user of internal errors d := New(100, time.Second, config, errHandler) d.RowChan <- &types.Row{...} d.RowChan <- &types.Row{...} d.RowChan <- &types.Row{...} ...
Package dynatomic provides a convenient wrapper API around using DynamoDB as highly available, concurrent, and performant asynchronous atomic counter Basic usage: // Initialize the dynatomic backround goroutine with a batch size of 100, // a wait time of a second, an AWS config and a function that will // notify the user of internal errors d := New(100, time.Second, config, errHandler) d.RowChan <- &types.Row{...} d.RowChan <- &types.Row{...} d.RowChan <- &types.Row{...} ...
types
Package types abstracts the table and row details making it easy to use dynamodb as an atomic counter
Package types abstracts the table and row details making it easy to use dynamodb as an atomic counter

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL