dynamoutilsv2

package
v1.5.18 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DynamoWriteBatchSize = 25
	DynamoReadBatchSize  = 100
)

Variables

This section is empty.

Functions

func AsSlice

func AsSlice(stream Stream) (values []map[string]types.AttributeValue, err error)

AsSlice read the stream fully and returns a slice.

func BufferedWriteItems

func BufferedWriteItems(ctx context.Context, db DynamoBatchWriteItem, requests []types.WriteRequest, table string, dynamoWriteBatchSize int) error

BufferedWriteItems writes items in batch with backoff and replay unprocessed items

Types

type DynamoBatchGetItem

type DynamoBatchGetItem interface {
	BatchGetItem(ctx context.Context, params *dynamodb.BatchGetItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.BatchGetItemOutput, error)
}

DynamoBatchGetItem is implemented by dynamodb.New()

type DynamoBatchWriteItem

type DynamoBatchWriteItem interface {
	BatchWriteItem(ctx context.Context, params *dynamodb.BatchWriteItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.BatchWriteItemOutput, error)
}

DynamoBatchWriteItem is implemented by dynamodb.New()

type DynamoGetStreamExecutor

type DynamoGetStreamExecutor struct {
	// contains filtered or unexported fields
}

DynamoGetStreamExecutor creates the query and execute in on the dynamoDB

type DynamoQuery

type DynamoQuery interface {
	Query(ctx context.Context, d *dynamodb.QueryInput, optFns ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)
}

DynamoQuery is implemented by dynamodb.New()

type GetStreamAdapter

type GetStreamAdapter interface {
	BatchGet(ctx context.Context, key []map[string]types.AttributeValue) (*dynamodb.BatchGetItemOutput, error)
}

GetStreamAdapter is building the batch query before passing it to dynamodb.

func NewGetBatchItem

func NewGetBatchItem(delegate DynamoBatchGetItem, tableName string, projectionExpression string) GetStreamAdapter

type Stream

type Stream interface {
	HasNext() bool                         // HasNext returns true if it has another element and no error has been raised
	Next() map[string]types.AttributeValue // Next return current element and move forward the cursor
	Error() error                          // Error returns the error that interrupted the Stream
	Count() int64                          // Count return the number of element found so far
}

Stream is inspired from Java streams to chain transformations in a functional programming style

func NewArrayStream

func NewArrayStream(results []map[string]types.AttributeValue) Stream

NewArrayStream creates a stream from a slice ; the slice will be updated.

func NewGetStream

func NewGetStream(ctx context.Context, executor GetStreamAdapter, keys []map[string]types.AttributeValue, bufferSize int64) Stream

NewGetStream batches requests to get each item by their natural key

Jump to

Keyboard shortcuts

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