Improvements to DynamoDB binding (#1823)
Ensure context propagation in PutItem and other minor changes Spin-off from PR adding contexts to input bindings Signed-off-by: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> Co-authored-by: Dapr Bot <56698301+dapr-bot@users.noreply.github.com>
This commit is contained in:
parent
1dc059482f
commit
2305dfb609
|
|
@ -20,6 +20,7 @@ import (
|
|||
"github.com/aws/aws-sdk-go/aws"
|
||||
"github.com/aws/aws-sdk-go/service/dynamodb"
|
||||
"github.com/aws/aws-sdk-go/service/dynamodb/dynamodbattribute"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
|
||||
aws_auth "github.com/dapr/components-contrib/authentication/aws"
|
||||
"github.com/dapr/components-contrib/bindings"
|
||||
|
|
@ -81,12 +82,10 @@ func (d *DynamoDB) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*bi
|
|||
return nil, err
|
||||
}
|
||||
|
||||
input := &dynamodb.PutItemInput{
|
||||
_, err = d.client.PutItemWithContext(ctx, &dynamodb.PutItemInput{
|
||||
Item: item,
|
||||
TableName: aws.String(d.table),
|
||||
}
|
||||
|
||||
_, err = d.client.PutItem(input)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -95,13 +94,8 @@ func (d *DynamoDB) Invoke(ctx context.Context, req *bindings.InvokeRequest) (*bi
|
|||
}
|
||||
|
||||
func (d *DynamoDB) getDynamoDBMetadata(spec bindings.Metadata) (*dynamoDBMetadata, error) {
|
||||
b, err := json.Marshal(spec.Properties)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var meta dynamoDBMetadata
|
||||
err = json.Unmarshal(b, &meta)
|
||||
err := mapstructure.WeakDecode(spec.Properties, &meta)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue