Skip to content

Commit 445d1c8

Browse files
committed
Add scoping
1 parent 8dff733 commit 445d1c8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

dynamodb_client/dynamo.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,24 @@ func NewDynamoDBClient(params DynamoConnectionParams) *DynamoClient {
3636
}
3737
svc := dynamodb.New(session.New(), &config)
3838
//svc.Handlers.Retry.PushFrontNamed(CheckThrottleHandler)
39+
3940
return &DynamoClient{
4041
svc,
41-
params.TableDescriptions,
42+
scopedTabledDescriptions(params.TableDescriptions, params.Scope),
4243
params.ServiceName,
4344
}
4445
}
4546

47+
func scopedTabledDescriptions(tds map[string]*dynamodb.TableDescription, scope string) map[string]*dynamodb.TableDescription {
48+
scopedTds := make(map[string]*dynamodb.TableDescription, len(tds))
49+
for name, td := range tds {
50+
newTd := *td
51+
newTd.TableName = aws.String(fmt.Sprintf("%s_%s", scope, name))
52+
scopedTds[name] = &newTd
53+
}
54+
return scopedTds
55+
}
56+
4657
type DynamoKey struct {
4758
HashKey string
4859
RangeKey string

0 commit comments

Comments
 (0)