1
0
mirror of https://github.com/mxpv/podsync.git synced 2024-05-11 05:55:04 +00:00

Better DynamoDB configuration

This commit is contained in:
Maksym Pavlenko
2018-12-03 22:58:39 -08:00
parent b92564d8d7
commit 75d7c40fcb
2 changed files with 6 additions and 13 deletions

@ -19,8 +19,6 @@ import (
)
const (
defaultRegion = "us-east-1"
pingTimeout = 5 * time.Second
pledgesPrimaryKey = "PatronID"
feedsPrimaryKey = "HashID"
@ -61,16 +59,8 @@ type Dynamo struct {
dynamo *dynamodb.DynamoDB
}
func NewDynamo(region, endpoint string) (Dynamo, error) {
if region == "" {
region = defaultRegion
}
sess, err := session.NewSession(&aws.Config{
Region: aws.String(region),
Endpoint: aws.String(endpoint),
})
func NewDynamo(cfg ...*aws.Config) (Dynamo, error) {
sess, err := session.NewSession(cfg...)
if err != nil {
return Dynamo{}, err
}

@ -15,7 +15,10 @@ func TestDynamo(t *testing.T) {
// docker run -it --rm -p 8000:8000 amazon/dynamodb-local
// noinspection ALL
func createDynamo(t *testing.T) storage {
d, err := NewDynamo("", "http://localhost:8000/")
d, err := NewDynamo(&aws.Config{
Region: aws.String("us-east-1"),
Endpoint: aws.String("http://localhost:8000/"),
})
require.NoError(t, err)
d.dynamo.DeleteTable(&dynamodb.DeleteTableInput{TableName: pledgesTableName})