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:
pkg/storage
@ -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})
|
||||
|
Reference in New Issue
Block a user