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

GetWithContext should return ConnWithContext? #16

Open
bzon opened this issue Mar 20, 2019 · 2 comments
Open

GetWithContext should return ConnWithContext? #16

bzon opened this issue Mar 20, 2019 · 2 comments
Assignees

Comments

@bzon
Copy link

bzon commented Mar 20, 2019

The code example here doesn't work https://opencensus.io/integrations/redis/go/gomodule_redigo/

I'm getting the error conn.DoContext undefined (type redis.Conn has no field or method DoContext)

@odeke-em
Copy link
Member

Hello @bzon thank you for the report and welcome to this project!

You need to do

	conn := redisPool.GetWithContext(ctx).(redis.ConnWithContext)
	defer conn.CloseContext(ctx)

notice the type assertion conn := redisPool.GetWithContext(ctx).(redis.ConnWithContext)
redis.Conn is an interface not a type so we can't change it, but that type assertion will enable you to handle DoContext. Let's update that example.

@bzon
Copy link
Author

bzon commented Mar 25, 2019

@odeke-em got it thanks.

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

2 participants