55package api
66
77import (
8+ "context"
89 "net/http"
910 "time"
1011
@@ -21,18 +22,19 @@ type WorkspaceFunc func(r *http.Request) (*sdk.Workspace, error)
2122
2223// Server is the HTTP API server wrapping an SDK client.
2324type Server struct {
24- clientFunc ClientFunc
25- workspaceFunc WorkspaceFunc
26- pile pile.RowQuerier
27- scoreboard * CachedEndpoint
28- scoreboardDetail * CachedEndpoint
29- scoreboardDump * CachedEndpoint
30- publicClient * sdk.Client // anonymous fallback for public reads (hosted mode)
31- browseCache * ReadCache // keyed by canonicalized query string
32- detailCache * ReadCache // keyed by item ID
33- environment string
34- mux * http.ServeMux
35- hosted bool // true when running in multi-tenant hosted mode
25+ clientFunc ClientFunc
26+ workspaceFunc WorkspaceFunc
27+ mutationInvalidator func (context.Context )
28+ pile pile.RowQuerier
29+ scoreboard * CachedEndpoint
30+ scoreboardDetail * CachedEndpoint
31+ scoreboardDump * CachedEndpoint
32+ publicClient * sdk.Client // anonymous fallback for public reads (hosted mode)
33+ browseCache * ReadCache // keyed by canonicalized query string
34+ detailCache * ReadCache // keyed by item ID
35+ environment string
36+ mux * http.ServeMux
37+ hosted bool // true when running in multi-tenant hosted mode
3638}
3739
3840// New creates a Server backed by the given SDK client.
@@ -115,6 +117,13 @@ func (s *Server) SetEnvironment(environment string) {
115117 s .environment = environment
116118}
117119
120+ // SetMutationInvalidator registers a callback that runs after successful
121+ // mutations invalidate API read caches. Hosted mode uses this to evict
122+ // resolver-owned caches that live beneath the HTTP layer.
123+ func (s * Server ) SetMutationInvalidator (fn func (context.Context )) {
124+ s .mutationInvalidator = fn
125+ }
126+
118127// ScoreboardHandler returns an http.HandlerFunc for the scoreboard endpoint.
119128func (s * Server ) ScoreboardHandler () http.HandlerFunc {
120129 return s .handleScoreboard
0 commit comments