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

proposal: Go2: replace context with channel/cancel and req.Store #21381

Closed
timakin opened this issue Aug 10, 2017 · 2 comments
Closed

proposal: Go2: replace context with channel/cancel and req.Store #21381

timakin opened this issue Aug 10, 2017 · 2 comments
Labels
FrozenDueToAge Proposal v2 A language change or incompatible library change
Milestone

Comments

@timakin
Copy link
Contributor

timakin commented Aug 10, 2017

As this author says, context package has too ambiguous role.
The spec notices that context should store only request-scoped variables,
and the main purpose of this package is cancellation of goroutine.

Removing all implementations of context is too drastic,
however, we should clarify the role of them.

So my proposal is splitting context implementation to channel/cancel package (that manages channels cancellation) and
Request.Store (a struct that saves request-scoped value until returning response).

@mvdan mvdan added the v2 A language change or incompatible library change label Aug 10, 2017
@gopherbot gopherbot added this to the Proposal milestone Aug 10, 2017
@OneOfOne
Copy link
Contributor

Exactly why I worked on cch, context is just too heavy for most operations and too complicated.

@ianlancetaylor
Copy link
Contributor

There are reasonable concerns with the context package, but this proposal doesn't address them. With this proposal, you still have to pass a Context value around everywhere you need it. Once you have to do that, the additional ability of Context to store request-scoped values is inconsequential. If you don't want to use it, then don't. The capability costs nothing if you don't use it. Splitting up the context package brings no significant benefit.

@golang golang locked and limited conversation to collaborators Mar 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Proposal v2 A language change or incompatible library change
Projects
None yet
Development

No branches or pull requests

5 participants