Documentation
¶
Overview ¶
Package dynamodbutils implements utilities used to interact with DynamoDB.
Package dynamodbutils implements utilities used to interact with DynamoDB.
Index ¶
- Variables
- func CreateTableIfNotExists(c Client, name string, cti dynamodb.CreateTableInput, maxAttempts uint16) error
- type Client
- type MockClient
- func (m *MockClient) CreateTable(_ context.Context, input *dynamodb.CreateTableInput, ...) (*dynamodb.CreateTableOutput, error)
- func (m *MockClient) DeleteItem(_ context.Context, input *dynamodb.DeleteItemInput, ...) (*dynamodb.DeleteItemOutput, error)
- func (m *MockClient) DescribeTable(_ context.Context, input *dynamodb.DescribeTableInput, ...) (*dynamodb.DescribeTableOutput, error)
- func (m *MockClient) GetItem(_ context.Context, input *dynamodb.GetItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.GetItemOutput, error)
- func (m *MockClient) PutItem(_ context.Context, input *dynamodb.PutItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.PutItemOutput, error)
- func (m *MockClient) Query(_ context.Context, input *dynamodb.QueryInput, ...) (*dynamodb.QueryOutput, error)
- func (m *MockClient) TablesToItems() cmap.ConcurrentMap[string, []map[string]types.AttributeValue]
- func (m *MockClient) TablesToKeys() cmap.ConcurrentMap[string, PrimaryKey]
- func (m *MockClient) UpdateItem(_ context.Context, input *dynamodb.UpdateItemInput, ...) (*dynamodb.UpdateItemOutput, error)
- type PrimaryKey
Constants ¶
This section is empty.
Variables ¶
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 ¶
func (m *MockClient) CreateTable(_ context.Context, input *dynamodb.CreateTableInput, _ ...func(*dynamodb.Options)) (*dynamodb.CreateTableOutput, error)
CreateTable creates a mock DynamoDB table.
func (*MockClient) DeleteItem ¶
func (m *MockClient) DeleteItem(_ context.Context, input *dynamodb.DeleteItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.DeleteItemOutput, error)
DeleteItem deletes an item from a mock DynamoDB table.
func (*MockClient) DescribeTable ¶
func (m *MockClient) DescribeTable(_ context.Context, input *dynamodb.DescribeTableInput, _ ...func(*dynamodb.Options)) (*dynamodb.DescribeTableOutput, error)
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 ¶
func (m *MockClient) UpdateItem(_ context.Context, input *dynamodb.UpdateItemInput, _ ...func(*dynamodb.Options)) (*dynamodb.UpdateItemOutput, error)
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).