Awesome
Dynatomic
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
- Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug
- Fork the repository on GitHub to start making your changes to the master branch (or branch off of it)
- Write a test which shows that the bug was fixed or that the feature works as expected
- Send a pull request and bug the maintainer until it gets merged and published