batchwriter

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2020 License: MIT Imports: 5 Imported by: 0

README

dynamodb-batchwriter

DyanmoDB BatchWriter

Documentation

Overview

Source: https://github.com/aws/aws-sdk-go-v2/pull/158/files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WrapDeleteItem

func WrapDeleteItem(deleteRequest *dynamodb.DeleteRequest) dynamodb.WriteRequest

WrapDeleteItem wraps a DeleteRequest to use with BatchWriter.Add.

func WrapPutItem

func WrapPutItem(putRequest *dynamodb.PutRequest) dynamodb.WriteRequest

WrapPutItem wraps a PutRequest to use with BatchWriter.Add.

Types

type BatchWriter

type BatchWriter struct {
	// Size of the buffer in which it will be flushed.
	// Do not set to a number above 25 as DynamoDB rejects BatchWrites with
	// more than 25 items.
	FlushAmount int
	// contains filtered or unexported fields
}

BatchWriter wraps a dynamodb client to expose a simple API that buffers requests and takes advantage of BatchWriteItem behind the scenes.

func New

func New(tableName string, client dynamodbiface.ClientAPI) (*BatchWriter, error)

New creates a new BatchWriter that will write to table `tableName` using `client`.

New will return an error if it fails to access the table information with a DescribeTableRequest.

func NewWithPrimaryKeys

func NewWithPrimaryKeys(tableName string, client dynamodbiface.ClientAPI,
	primaryKeys []string) *BatchWriter

NewWithPrimaryKeys creates a new BatchWriter using `primaryKeys` as the specified primary keys instead of getting them from a call to DescribeTable.

func (*BatchWriter) Add

func (b *BatchWriter) Add(writeRequest dynamodb.WriteRequest) error

Add is used to queue a PutItem or DeleteItem operation.

Most normally, it will be used in conjunction with WrapPutItem and WrapDeleteItem.

func (*BatchWriter) Empty

func (b *BatchWriter) Empty() bool

Empty returns whether or not the request buffer is empty.

func (*BatchWriter) Flush

func (b *BatchWriter) Flush() error

Flush makes a BatchWriteItem with some or all requests that have been added so far to the buffer by means of Add.

Any unprocessed items sent in the response will be added to the end of the buffer, to be sent later.

Jump to

Keyboard shortcuts

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