harlow / kinesis-consumer

Golang library for consuming Kinesis stream data
MIT License
263 stars 88 forks source link

Signiture change for kinesis WithClient() #143

Closed SeenYang closed 2 years ago

SeenYang commented 2 years ago

Hi, For release 0.3.5, The method signiture is:

func WithClient(client kinesisiface.KinesisAPI) Option {
    return func(c *Consumer) {
        c.client = client
    }
}

Current master version is:

// WithClient overrides the default client
func WithClient(client kinesisClient) Option {
    return func(c *Consumer) {
        c.client = client
    }
}

it's throwing our exception if we want to use latest aws-sdk-go-v2 image

Cheers Y

harlow commented 2 years ago

@SeenYang which version are you getting the error with? master?

The 0.3.5 cut is not designed to use the AWS SDK v2

v2 sdk doesn't support kinesisiface.KinesisAPI so I created a local interface:

// kinesisClient defines the interface of functions needed for the consumer
type kinesisClient interface {
    GetRecords(ctx context.Context, params *kinesis.GetRecordsInput, optFns ...func(*kinesis.Options)) (*kinesis.GetRecordsOutput, error)
    ListShards(ctx context.Context, params *kinesis.ListShardsInput, optFns ...func(*kinesis.Options)) (*kinesis.ListShardsOutput, error)
    GetShardIterator(ctx context.Context, params *kinesis.GetShardIteratorInput, optFns ...func(*kinesis.Options)) (*kinesis.GetShardIteratorOutput, error)
}

which the v2 client implements

bscaka345 commented 2 years ago

I get a similar error using the examples consumer code. For some reason, it still tries to match with kinesisiface.KinesisAPI unsuccessfully.

Kinesis-Consumer-Client-Compile-Error

rodmcelrath commented 2 years ago

I came here to say this and ask about a fix.

command-line-arguments

./kin.go:60:22: cannot use client (type "github.com/aws/aws-sdk-go-v2/service/kinesis".Client) as type kinesisiface.KinesisAPI in argument to consumer.WithClient: "github.com/aws/aws-sdk-go-v2/service/kinesis".Client does not implement kinesisiface.KinesisAPI (wrong type for AddTagsToStream method) have AddTagsToStream(context.Context, "github.com/aws/aws-sdk-go-v2/service/kinesis".AddTagsToStreamInput, ...func("github.com/aws/aws-sdk-go-v2/service/kinesis".Options)) ("github.com/aws/aws-sdk-go-v2/service/kinesis".AddTagsToStreamOutput, error) want AddTagsToStream("github.com/aws/aws-sdk-go/service/kinesis".AddTagsToStreamInput) (*"github.com/aws/aws-sdk-go/service/kinesis".AddTagsToStreamOutput, error)

rodmcelrath commented 2 years ago

OK - I believe I've figured this out. Mixing Kinesis-client that needs v2 apis with a system built with v1 apis. Clearly I need to update my SDK version.

I came here to say this and ask about a fix.

command-line-arguments

./kin.go:60:22: cannot use client (type "github.com/aws/aws-sdk-go-v2/service/kinesis".Client) as type kinesisiface.KinesisAPI in argument to consumer.WithClient: "github.com/aws/aws-sdk-go-v2/service/kinesis".Client does not implement kinesisiface.KinesisAPI (wrong type for AddTagsToStream method) have AddTagsToStream(context.Context, "github.com/aws/aws-sdk-go-v2/service/kinesis".AddTagsToStreamInput, ...func("github.com/aws/aws-sdk-go-v2/service/kinesis".Options)) ("github.com/aws/aws-sdk-go-v2/service/kinesis".AddTagsToStreamOutput, error) want AddTagsToStream("github.com/aws/aws-sdk-go/service/kinesis".AddTagsToStreamInput) (*"github.com/aws/aws-sdk-go/service/kinesis".AddTagsToStreamOutput, error)

SeenYang commented 2 years ago

OK - I believe I've figured this out. Mixing Kinesis-client that needs v2 apis with a system built with v1 apis. Clearly I need to update my SDK version.

I came here to say this and ask about a fix.

command-line-arguments

./kin.go:60:22: cannot use client (type "github.com/aws/aws-sdk-go-v2/service/kinesis".Client) as type kinesisiface.KinesisAPI in argument to consumer.WithClient: "github.com/aws/aws-sdk-go-v2/service/kinesis".Client does not implement kinesisiface.KinesisAPI (wrong type for AddTagsToStream method) have AddTagsToStream(context.Context, "github.com/aws/aws-sdk-go-v2/service/kinesis".AddTagsToStreamInput, ...func("github.com/aws/aws-sdk-go-v2/service/kinesis".Options)) ("github.com/aws/aws-sdk-go-v2/service/kinesis".AddTagsToStreamOutput, error) want AddTagsToStream("github.com/aws/aws-sdk-go/service/kinesis".AddTagsToStreamInput) (*"github.com/aws/aws-sdk-go/service/kinesis".AddTagsToStreamOutput, error)

Hi Yes. Sorry for late reply. I figured out the same case and might need to make sure they are using the same.

SeenYang commented 2 years ago

As discussed, I recon rodmcelrath making the point thus I will close the comment. Please reopen or link to new issue if further issue found.