Skip to content

context.Context can be nil #1098

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

Closed
kollektiv opened this issue Jul 25, 2019 · 2 comments
Closed

context.Context can be nil #1098

kollektiv opened this issue Jul 25, 2019 · 2 comments

Comments

@kollektiv
Copy link

kollektiv commented Jul 25, 2019

Version: 6bc7daa

Certain methods, such as func (c *Client) Process(cmd Cmder) error, will default pass a nil context. https://github.com/go-redis/redis/blob/6bc7daa5b1e86745a6976ac1c4dfe6c76ea6af1f/redis.go#L511

What are your thoughts on passing c.Context() (defaults to context.Background()) instead of c.ctx so the context is never nil? It's strongly recommended on https://golang.org/pkg/context/ to not pass a nil context.

There are a few other places where c.ctx is passed where c.Context() could be passed instead: ring.go, sentinel.go, and tx.go

@vmihailenco
Copy link
Collaborator

c.ctx is supposed to never have a nil value - it is initialized with context.Background() when client is created. c.Context() just returns c,ctx so there will not be any difference.

Do I miss anything?

@kollektiv
Copy link
Author

You're right, I was using a version prior to #1080. c.ctx is always initialized now

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