3 ms·
The dual purposes of contexts (cancellation vs. value propagation) is one of the biggest warts in the go stdlib. It really feels like a right hand / left hand s
by morelisp 6y ago
The dual purposes of contexts (cancellation vs. value propagation) is one of the biggest warts in the go stdlib. It really feels like a right hand / left hand situation within Google.
They are a pretty good tool for handling cancellation. They are abysmal at carrying values - no type safety, slow, and as the documentation notes require extreme care in key types. The type safety is probably foregone given the constraints of Go's type system, but the other two are direct consequences of marrying the values to the same interface requirements (additive only, mandatory ancestors) as cancellation, which are too weak for a good kv map.
We simply don't use the value features unless we're using one of the HTTP routers that forces us to, and then only for the router's parameters.
- zmj 6y agoThe commonality is that both should flow across serialization boundaries, like RPC calls to downstream services.