aws / aws-dax-go

AWS DAX SDK for the Go programming language. https://aws.amazon.com/dynamodb/dax
Apache License 2.0
47 stars 48 forks source link

Implement newly added Interfaces to dynamodbiface in aws-sdk-go #38

Closed cthedark closed 1 year ago

cthedark commented 1 year ago

The merge to main on 8-18-2022 added import related interfaces, which broke the build.

https://github.com/aws/aws-sdk-go/pull/4527/files#diff-7079cf4d8390f029e40fff0af783c201db0882743f5805151f03caab828c686dR130-R210

xerebz commented 1 year ago

What is the fix? Is there a workaround?

MMOSimca commented 1 year ago

The workaround is to not reuse the AWS-SDK-Go interface called DynamoDBAPI and instead implement your own interface that contains a subset of its methods that are relevant to you.

For my team's service, I did something like this:

// Subset of the interface dynamodbiface.DynamoDBAPI from the Go AWS SDK
type DDBAPI interface {
    BatchExecuteStatement(*dynamodb.BatchExecuteStatementInput) (*dynamodb.BatchExecuteStatementOutput, error)
    BatchExecuteStatementWithContext(aws.Context, *dynamodb.BatchExecuteStatementInput, ...request.Option) (*dynamodb.BatchExecuteStatementOutput, error)
    BatchExecuteStatementRequest(*dynamodb.BatchExecuteStatementInput) (*request.Request, *dynamodb.BatchExecuteStatementOutput)

    BatchGetItem(*dynamodb.BatchGetItemInput) (*dynamodb.BatchGetItemOutput, error)
    BatchGetItemWithContext(aws.Context, *dynamodb.BatchGetItemInput, ...request.Option) (*dynamodb.BatchGetItemOutput, error)
    BatchGetItemRequest(*dynamodb.BatchGetItemInput) (*request.Request, *dynamodb.BatchGetItemOutput)

    BatchGetItemPages(*dynamodb.BatchGetItemInput, func(*dynamodb.BatchGetItemOutput, bool) bool) error
    BatchGetItemPagesWithContext(aws.Context, *dynamodb.BatchGetItemInput, func(*dynamodb.BatchGetItemOutput, bool) bool, ...request.Option) error

    BatchWriteItem(*dynamodb.BatchWriteItemInput) (*dynamodb.BatchWriteItemOutput, error)
    BatchWriteItemWithContext(aws.Context, *dynamodb.BatchWriteItemInput, ...request.Option) (*dynamodb.BatchWriteItemOutput, error)
    BatchWriteItemRequest(*dynamodb.BatchWriteItemInput) (*request.Request, *dynamodb.BatchWriteItemOutput)

    GetItem(*dynamodb.GetItemInput) (*dynamodb.GetItemOutput, error)
    GetItemWithContext(aws.Context, *dynamodb.GetItemInput, ...request.Option) (*dynamodb.GetItemOutput, error)
    GetItemRequest(*dynamodb.GetItemInput) (*request.Request, *dynamodb.GetItemOutput)

    PutItem(*dynamodb.PutItemInput) (*dynamodb.PutItemOutput, error)
    PutItemWithContext(aws.Context, *dynamodb.PutItemInput, ...request.Option) (*dynamodb.PutItemOutput, error)
    PutItemRequest(*dynamodb.PutItemInput) (*request.Request, *dynamodb.PutItemOutput)

    Query(*dynamodb.QueryInput) (*dynamodb.QueryOutput, error)
    QueryWithContext(aws.Context, *dynamodb.QueryInput, ...request.Option) (*dynamodb.QueryOutput, error)
    QueryRequest(*dynamodb.QueryInput) (*request.Request, *dynamodb.QueryOutput)

    QueryPages(*dynamodb.QueryInput, func(*dynamodb.QueryOutput, bool) bool) error
    QueryPagesWithContext(aws.Context, *dynamodb.QueryInput, func(*dynamodb.QueryOutput, bool) bool, ...request.Option) error
}

and then replaced all references in my project to DynamoDBAPI with DDBAPI.

It's not particularly elegant, though, and you may have to add new methods to your interface subset in the future.

sumitsa-amazon commented 1 year ago

Thank you for raising this issue. The new interfaces were added to DAX SDK as part commit. Closing this issue, please feel free to reopen if you still continue face this issue.

miparnisari commented 2 months ago

@sumitsa-amazon, it broke again. https://github.com/aws/aws-sdk-go/blob/main/service/dynamodb/dynamodbiface/interface.go#L62-L317

Can you please update it?