~/talk

How to correctly use package context

Talkat Golang UK 2017 · 2017-08-16..08-18· [go]
slides:none on file

Go 1.7 context provides request-wide cancellation and scoped values; use context.Background at RPC entry, pass Context as the first arg or on a request struct, and prefer errgroup.WithContext for parallel RPCs so the first error cancels the rest. Always call the cancel func to avoid timer leaks. Store only immutable request-scoped metadata, scope keys with a private type, and let values inform not control logic; follow always call cancel and use error group for fan‑out.

AI-written summary · about

  1. 0:00Introduction
  2. 0:55Outline
  3. 1:25Why does context exist
  4. 2:19Multiple RPC calls
  5. 4:24The bigger problem
  6. 4:43Threadlocal variables
  7. 5:08Tree
  8. 5:23Context chain
  9. 6:12API
  10. 6:51When to use context
  11. 7:42How to create context
  12. 8:19How to integrate context into your API
  13. 9:37Where to put context
  14. 10:55Closing context
  15. 12:37Error groups
  16. 15:49Scoped values
  17. 17:17Scope keyspace
  18. 18:27Immutability
  19. 19:18Context Values
  20. 20:27Problem with Context Values
  21. 21:15Summary of Code
  22. 21:37Function Signature
  23. 22:28Refactoring
  24. 23:10Request ID
  25. 24:26Database Connection
  26. 25:00Creative Debugging
  27. 25:17CV Trace
  28. 26:32Requests of Value
  29. 27:30Abuse of Context
  30. 28:46Summary of Context
  31. 29:26Summary of Operations
  32. 30:36Questions
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.