Struct Embedding, Instrumentation and Code Generation
summary
Codebase replaces a brittle middleware chain with struct embedding layers that wrap a concrete SQL store to provide caching, timing, tracing, retries and search delegation to Elasticsearch/Blee. Generators use go/ast plus templates and gofmt to emit timer, OpenTracing and retry wrappers automatically; timer metrics feed Prometheus histograms. Retry layer loops on serializable repeatable errors and gives up after three attempts. Solution reduces scattered code and works well in production but requires a homogeneous interface and careful handling because embedding is not inheritance.
AI-written summary · about
chapters (13)
- 0:00Marmos architecture intro
- 3:24Middleware pattern for caching
- 8:19Struct embedding for stores
- 12:46Struct embedding challenges
- 15:14Instrumenting layers
- 18:46Timer layer generation
- 21:37Open tracing layer
- 23:45Retry layer for DB errors
- 27:19Code generation in Marmos
- 29:24Storage query delegation
- 32:49Final architecture wrap
- 36:01Drawbacks and homogeneity
- 37:24Key takeaways
related talks
45mEmbedding
23mCompile Time Code Weaving in Go, Large Systems Debugging/Profiling
23mCompile Time Code Weaving in Go, Large Systems Debugging/Profiling
31mGo tricks from the trenches
53mStupid Gopher Tricks
21mBuilding APIs in Go The Stack Without a Framework
17mExtreme Engineering-Elements of Building a High -scale Broking Application
43mAutomatically Instrument Your Go Source Code with Orchestrion
