# README
'Prom' for AWS DynamoDB (https://github.com/aws/aws-sdk-go/tree/main/service/dynamodb)
Supported/Tested libraries/drivers+version:
github.com/aws/aws-sdk-go v1.44.44
.
Usage:
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/credentials"
"github.com/btnguyen2k/prom/dynamodb"
)
// credentials from env.AWS_ACCESS_KEY_ID & env.AWS_SECRET_ACCESS_KEY & env.AWS_SESSION_TOKEN
cfg := &aws.Config{
Region: aws.String(region),
Credentials: credentials.NewEnvCredentials(),
}
timeoutMs := 10000
awsDynamodbConnect, err := dynamodb.NewAwsDynamodbConnect(cfg, nil, nil, timeoutMs)
if err != nil {
panic(err)
}
// from now on, the AwsDynamodbConnect instance can be shared & used by all goroutines within the application
See more:
# Functions
AwsDynamodbEqualsBuilder builds a expression.ConditionBuilder with condition attr1=value1 AND attr1=value1 AND..
AwsDynamodbExistsAllBuilder builds an expression.ConditionBuilder where all attributes must exist.
AwsDynamodbNotExistsAllBuilder builds a expression.ConditionBuilder where all attributes must not exist.
AwsDynamodbToAttributeSet converts a Go value to DynamoDB's set.
AwsDynamodbToAttributeValue converts a Go value to DynamoDB's attribute value.
AwsDynamodbWaitForGsiStatus periodically checks if table's GSI status reaches a desired value, or timeout.
AwsDynamodbWaitForTableStatus periodically checks if table's status reaches a desired value, or timeout.
AwsIgnoreErrorIfMatched returns nil if err is an awserr.Error and its code is in the "exclude" list.
AwsIgnoreTransactErrorIfMatched returns nil if err is a *dynamodb.TransactionCanceledException and its reason's code is in the "exclude" list.
IsAwsError returns true if err is an awserr.Error and its code equals to awsErrCode.
NewAwsDynamodbConnect constructs a new AwsDynamodbConnect instance.
# Constants
AwsAttrTypeBinary is alias name of AWS DynamoDB attribute type "binary".
AwsAttrTypeNumber is alias name of AWS DynamoDB attribute type "number".
AwsAttrTypeString is alias name of AWS DynamoDB attribute type "string".
AwsDynamodbNoIndex indicates that no index will be used.
AwsKeyTypePartition is alias name of AWS DynamoDB key type "partition".
AwsKeyTypeSort is alias name of AWS DynamoDB key type "sort/range".
# Variables
ErrTimeout is returned by AwsDynamodbWaitForTableStatus or AwsDynamodbWaitForGsiStatus to indicate that timeout occurred before we reach the desired status.
# Structs
AwsDynamodbConnect holds an AWS DynamoDB client (https://github.com/aws/aws-sdk-go/tree/master/service/dynamodb) that can be shared within the application.
AwsDynamodbNameAndType defines a generic name & type pair.
AwsQueryOpt provides additional options to AwsDynamodbConnect.QueryItems and AwsDynamodbConnect.QueryItemsWithCallback.
DynamoDbProxy is a proxy that can be used as replacement for dynamodb.DynamoDB.
# Type aliases
AwsDynamodbItem defines a generic structure for DynamoDB item.
AwsDynamodbItemCallback defines callback interface for "scan"/"query" operation.