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

Cannot create DAX client with session - InvalidParameter: custom handlers not supported #17

Closed edulopezTriv closed 4 years ago

edulopezTriv commented 4 years ago

I'm trying to create a DAX client with dax.NewWithSession using the same session I use for creating a dynamo client. I can confirm it works with dynamo.

Sample

sess, err := GetSession()
if err != nil {
    return nil, err
}
if useDAX {
    svc, err = dax.NewWithSession(sess)
} else {
    svc = dynamodb.New(sess)
}

this is the error I have when calling dax.NewWithSession

InvalidParameter: custom handlers not supported

If you read the code from aws-dax-go that error comes from client.ValidateHandlers

What should we do to create a new DAX client using our aws session?

Env

github.com/aws/aws-dax-go v1.1.1
github.com/aws/aws-sdk-go v1.19.48
VasilyFomin commented 4 years ago

We indeed do not support custom handlers, but probably a warning will be sufficient, otherwise you'll have to provide/modify a separate session for the Dax client.

Are you providing custom handlers?

edulopezTriv commented 4 years ago

We indeed do not support custom handlers, but probably a warning will be sufficient, otherwise you'll have to provide/modify a separate session for the Dax client.

Are you providing custom handlers?

Nope. I'm just using my session object created with AWS sdk.

I'm worried that dax.NewWithSession has a bug.

dspinei commented 4 years ago

The error reported by @edulopezTriv can be reproduced simply with:

    sess, _ := session.NewSession()
    return dax.NewWithSession(*sess)

Looks like a default Session created with aws-sdk-go already contains handlers that are considered custom by the dax sdk.

Env

github.com/aws/aws-dax-go v1.1.4
github.com/aws/aws-sdk-go v1.18.6
VasilyFomin commented 4 years ago

After looking into it somewhat more, I think we're going to deprecate this constructor all together.

The reason we have validations is because DAX doesn't use custom configurations and handlers and we want to make sure a customer is aware of this. Essentially the only fields we're using from the session objects are some of the configurations:

https://github.com/aws/aws-dax-go/blob/19b34c5c99ea4b76610dcbae7d87fd572de012df/dax/service.go#L86-L107

Which essentially means you'll have to modify your existing session anyway, to get it working with DAX, at which point you might as well create a new DAX configuration.

What's your use case when you use an existing session? How do you set the dax endpoint?

edulopezTriv commented 4 years ago

The thing is I may use that session to any other thing in my project. I rather have a NewDaxWithCredentials(session) that takes what it needs from it instead of having to change it.

VasilyFomin commented 4 years ago

The problem is it wont' work, because you will still have to modify the session's Endpoint to point to your dax cluster

dspinei commented 4 years ago

you will still have to modify the session's Endpoint to point to your dax cluster

I don't think that's the issue. I think the expectation is that the following code, that is familiar across AWS SDKs, works:

sess, _ := session.NewSession(&aws.Config{
    Endpoint: aws.String(daxURL),
    Region:   aws.String(daxRegion),
})
return dax.NewWithSession(*sess)
lyaoxion commented 4 years ago

This was fixed in v1.2.0. Creation of DAX client from a Session will not throw out an error as long as all required configurations is provided in the Session.

hmayi commented 5 months ago

@lyaoxion @dspinei Have you guys upgraded the DAX client using SDKV2?

miparnisari commented 5 months ago

@hmayi there is an open PR from the community: https://github.com/aws/aws-dax-go/pull/43

But it hasn't received any attention from the maintainers of DAX. ☹️

hmayi commented 5 months ago

Thanks for the reply. Were you able to create sessions with SDK1?

Regards Hiranmayi.

On Thu, Feb 8, 2024 at 11:42 PM Maria Ines Parnisari < @.***> wrote:

@hmayi https://github.com/hmayi there is an open PR from the community:

43 https://github.com/aws/aws-dax-go/pull/43

But it hasn't received any attention from the maintainers of DAX. ☹️

— Reply to this email directly, view it on GitHub https://github.com/aws/aws-dax-go/issues/17#issuecomment-1935325445, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAN6RG7DMOQ7GX3NPGSNXLTYSWSMZAVCNFSM4IYYUIW2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCOJTGUZTENJUGQ2Q . You are receiving this because you were mentioned.Message ID: @.***>