Summary
platform/data/provider.go:15-31:
type Setter interface {
AddDataToContext(ctx context.Context, data ...map[string]any) (context.Context, error)
}
Two friction points showing up at every call site:
-
The variadic ...map[string]any is rarely used variadically — most call sites pass exactly one map. The variadic form forces processValue to special-case *http.Request unwrapping (platform/data/contextProvider.go:101-126), which suggests ...any would be more honest if we want to keep the variadic at all.
-
The (ctx, error) return is awkward when the call has no real error path. ContextProvider only errors when its key is empty (a programming error). Callers always have to do the ctx, err := ...; if err != nil { ... } dance even when there's nothing to recover from.
Proposal
Pick one of:
- Drop the variadic and document one map per call.
- Change the variadic to
...any and document the support matrix (map[string]any, *http.Request, structs, etc.).
- Provide a no-error helper for the common case alongside the interface (e.g.
MustAddData(ctx, data) or WithRuntimeData(ctx, data) context.Context).
Files
platform/data/provider.go:15-31
platform/data/contextProvider.go:53-93
platform/data/staticProvider.go:40-45
platform/data/compositeProvider.go:89-150
This is a breaking-change candidate for v1.
Summary
platform/data/provider.go:15-31:Two friction points showing up at every call site:
The variadic
...map[string]anyis rarely used variadically — most call sites pass exactly one map. The variadic form forcesprocessValueto special-case*http.Requestunwrapping (platform/data/contextProvider.go:101-126), which suggests...anywould be more honest if we want to keep the variadic at all.The
(ctx, error)return is awkward when the call has no real error path.ContextProvideronly errors when its key is empty (a programming error). Callers always have to do thectx, err := ...; if err != nil { ... }dance even when there's nothing to recover from.Proposal
Pick one of:
...anyand document the support matrix (map[string]any,*http.Request, structs, etc.).MustAddData(ctx, data)orWithRuntimeData(ctx, data) context.Context).Files
platform/data/provider.go:15-31platform/data/contextProvider.go:53-93platform/data/staticProvider.go:40-45platform/data/compositeProvider.go:89-150This is a breaking-change candidate for v1.