GopherCon 2022: Adam Berkan - How Should We Access Global Resources?

Опубликовано: 14 Ноябрь 2024
на канале: Gopher Academy
696
21

How should we access global & semi-global resources like the database, the logger, or request headers? Global variables suck. Passing every resource as a parameter is excessive. Stuffing them in a context is not type-safe. Hiding them in a `server` object hides which ones are actually used.

At Khan Academy, we've been creating an interface object that provides access to all these resources but allows the function to declare which parts of the interface it requires.

Based on my blog post: https://blog.khanacademy.org/statical..., check out this Lightning Talk to learn more!