-
Notifications
You must be signed in to change notification settings - Fork 436
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
Conversation
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.
@@ -21,12 +21,16 @@ type Client struct { | |||
*params | |||
} | |||
|
|||
var _ redis.Cmdable = (*Client)(nil) |
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
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...
There was a problem hiding this 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!
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.
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.
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
implementsredis.Pipeliner
, the signature is different and just because of that detail it's impossible to useClient
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 genericredis.Cmdable
...