dynatomic

package
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 Imports: 6 Imported by: 0

Documentation

Overview

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{...}
...
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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dynatomic

type Dynatomic struct {
	RowChan    chan *types.Row
	Config     *aws.Config
	ErrHandler func(loc string, err error)

	BatchSize int
	WaitTime  time.Duration
	// contains filtered or unexported fields
}

Dynatomic struct contains all information necessary to perform bulk, asynchronous writes

func New

func New(batchSize int, waitTime time.Duration, config *aws.Config, errHandler func(loc string, err error)) *Dynatomic

New creates a dynatomic struct listening to the RowChan for writes

func (*Dynatomic) Done

func (d *Dynatomic) Done()

Done takes the last of the messages ready to be sent and destroys the running goroutine

Jump to

Keyboard shortcuts

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