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

contrib/go-redis/redis: make go-redis traced Client a true redis.Cmdable #329

Merged
merged 1 commit into from
Sep 11, 2018

Conversation

ufoot
Copy link
Contributor

@ufoot ufoot commented Sep 11, 2018

I'm experiencing problems using a traced client. The baseline is: I try to have the same code running when it's traced and when it's not, keeping an option "I want to trace this or not" at runtime.

As I view it one option is to consider the client is just a https://godoc.org/github.com/go-redis/redis#Cmdable be it traced or not.

Now I hit a problem, the Pipeline() func has the wrong prototype. While it's true *Pipeliner implements redis.Pipeliner, the signature is different and just because of that detail it's impossible to use Client as a generic Cmdable.

This patch changes the prototype. It is a breaking change, as I had to update a test. Indeed, caller
can not assume Pipeline() returns a concrete *Pipeliner. So a cast is required. But OTOH the client is a truely generic redis.Cmdable...

Previous prototype of Pipeline would yield an error when trying
to use the client as a redis.Cmdable. Now Pipeline returns an
interface and not a concrete type.
@ufoot ufoot requested a review from gbbr September 11, 2018 13:24
@@ -21,12 +21,16 @@ type Client struct {
*params
}

var _ redis.Cmdable = (*Client)(nil)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not compile without changing the prototype of Pipeline().

@@ -59,7 +59,7 @@ func TestPipeline(t *testing.T) {
pipeline.Expire("pipeline_counter", time.Hour)

// Exec with context test
pipeline.ExecWithContext(context.Background())
pipeline.(*Pipeliner).ExecWithContext(context.Background())
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change, test needed to be updated...

@gbbr gbbr added this to the 1.3.0 milestone Sep 11, 2018
@gbbr gbbr added the apm:ecosystem contrib/* related feature requests or bugs label Sep 11, 2018
@gbbr gbbr changed the title contrib: make go-redis traced Client a true redis.Cmdable contrib/go-redis/redis: make go-redis traced Client a true redis.Cmdable Sep 11, 2018
Copy link
Contributor

@gbbr gbbr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep! This is definitely more correct. And thanks for the inline comments. They helped!

@gbbr gbbr merged commit ba8f967 into v1 Sep 11, 2018
@gbbr gbbr deleted the christian/goredispipeliner branch September 11, 2018 13:31
gbbr pushed a commit that referenced this pull request Sep 11, 2018
Previous prototype of Pipeline would yield an error when trying
to use the client as a redis.Cmdable. Now Pipeline returns an
interface and not a concrete type.
@gbbr
Copy link
Contributor

gbbr commented Sep 19, 2018

@ufoot this is now out in 1.3.0. Feel free to update! And thank you once more for contributing.

mingrammer pushed a commit to mingrammer/dd-trace-go that referenced this pull request Dec 22, 2020
Previous prototype of Pipeline would yield an error when trying
to use the client as a redis.Cmdable. Now Pipeline returns an
interface and not a concrete type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
apm:ecosystem contrib/* related feature requests or bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants