dynamodbutils

package
v0.0.0-...-963cbb1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package dynamodbutils implements utilities used to interact with DynamoDB.

Package dynamodbutils implements utilities used to interact with DynamoDB.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFailedToCreateTable is returned when a table cannot be created if it does not exist.
	ErrFailedToCreateTable = errors.New("failed to create DynamoDB table if it does not exist")
)

Functions

func CreateTableIfNotExists

func CreateTableIfNotExists(c Client, name string, cti dynamodb.CreateTableInput, maxAttempts uint16) error

CreateTableIfNotExists creates a table if it does not exist.

Types

type Client

type Client interface {
	GetItem(ctx context.Context, params *dynamodb.GetItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
	PutItem(ctx context.Context, params *dynamodb.PutItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
	UpdateItem(ctx context.Context, params *dynamodb.UpdateItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.UpdateItemOutput, error)
	DeleteItem(ctx context.Context, params *dynamodb.DeleteItemInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DeleteItemOutput, error)
	CreateTable(ctx context.Context, params *dynamodb.CreateTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.CreateTableOutput, error)
	DescribeTable(ctx context.Context, params *dynamodb.DescribeTableInput, optFns ...func(*dynamodb.Options)) (*dynamodb.DescribeTableOutput, error)
	Query(ctx context.Context, params *dynamodb.QueryInput, optFns ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)
}

Client defines methods implemented by AWS SDK for Go v2's DynamoDB client.

type MockClient

type MockClient struct {
	Client
	// contains filtered or unexported fields
}

MockClient stores the data structures used to mock DynamoDB.

func NewMockClient

func NewMockClient() *MockClient

NewMockClient creates a new MockClient instance.

func (*MockClient) CreateTable

CreateTable creates a mock DynamoDB table.

func (*MockClient) DeleteItem

DeleteItem deletes an item from a mock DynamoDB table.

func (*MockClient) DescribeTable

DescribeTable describes a mock DynamoDB table.

func (*MockClient) GetItem

func (m *MockClient) GetItem(_ context.Context, input *dynamodb.GetItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)

GetItem gets a shallow clone of an item in a mock DynamoDB table.

func (*MockClient) PutItem

func (m *MockClient) PutItem(_ context.Context, input *dynamodb.PutItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)

PutItem puts an item into a mock DynamoDB table.

func (*MockClient) Query

func (m *MockClient) Query(_ context.Context, input *dynamodb.QueryInput, optFns ...func(*dynamodb.Options)) (*dynamodb.QueryOutput, error)

Query queries a mock DynamoDB table.

func (*MockClient) TablesToItems

func (m *MockClient) TablesToItems() cmap.ConcurrentMap[string, []map[string]types.AttributeValue]

TablesToItems gets the map of DynamoDB tables to DynamoDB items.

func (*MockClient) TablesToKeys

func (m *MockClient) TablesToKeys() cmap.ConcurrentMap[string, PrimaryKey]

TablesToKeys gets the map of DynamoDB tables to primary keys.

func (*MockClient) UpdateItem

UpdateItem does nothing since it is not required to be implemented.

type PrimaryKey

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

PrimaryKey stores the partition and sort key for a DynamoDB table (a primary key is composed of a partition and sort key).

Jump to

Keyboard shortcuts

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