Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
edulopezTriv opened this issue Sep 20, 2019 · 11 comments

Comments

@edulopezTriv
Copy link

edulopezTriv commented Sep 20, 2019

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
Copy link
Contributor

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
Copy link
Author

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
Copy link

dspinei commented Nov 14, 2019

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
Copy link
Contributor

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:

aws-dax-go/dax/service.go

Lines 86 to 107 in 19b34c5

func (c *Config) mergeFrom(ac aws.Config) {
if r := ac.MaxRetries; r != nil {
c.WriteRetries = *r
c.ReadRetries = *r
}
if ac.Logger != nil {
c.Logger = ac.Logger
}
if ac.LogLevel != nil {
c.LogLevel = *ac.LogLevel
}
if ac.Credentials != nil {
c.Credentials = ac.Credentials
}
if ac.Endpoint != nil {
c.HostPorts = []string{*ac.Endpoint}
}
if ac.Region != nil {
c.Region = *ac.Region
}
}

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
Copy link
Author

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
Copy link
Contributor

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

@dspinei
Copy link

dspinei commented Nov 21, 2019

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
Copy link
Contributor

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
Copy link

hmayi commented Feb 9, 2024

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

@miparnisari
Copy link

@hmayi there is an open PR from the community: #43

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

@hmayi
Copy link

hmayi commented Feb 9, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants