registry.go ×3

Frontier kind: Code frontier

unlabeled · c_37456f16ec68

37 tests · 2122 LOC · 90 files · introduces 0 tests · 25 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
3 ranges25 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
316 ranges2122 lines · 90 files · Browse complete extent
All tests (intent)
37 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 25 introduced LOC across 3 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/namespace/nsregistry/registry.go 25 introduced LOC · 3 ranges

Open complete file

277 }
278
279 > func (r *registry) RegisterStateChangeCallback(key any, cb namespace.StateChangeCallbackFn) { registry.go
280 > // Store callback first to avoid race where watch events arrive between reading the namespace snapshot and storing the
281 > // callback. This ensures no events are missed, but introduces a different trade-off: The callback may receive duplicate
282 > // calls for the same namespace if a watch event arrives while we're iterating through the catch-up loop below. For
283 > // example:
284 > // 1. Callback is stored in stateChangeCallbacks
285 > // 2. Watch event arrives for namespace X, callback is invoked
286 > // 3. Catch-up loop reaches namespace X, callback is invoked again
287 > //
288 > // This is acceptable because callbacks are rarely added (so unlikely to trigger this) and callbacks should be idempotent anyway.
289 > callbackWithTiming := func(ns *namespace.Namespace, deletedFromDb bool) {
290 > // Track callback duration so we can identify slow callbacks
291 > start := time.Now()
292 > defer func() {
293 > duration := time.Since(start)
294 > if duration > slowCallbackDuration {
295 metrics.NamespaceRegistrySlowCallbacks.With(r.metricsHandler).Record(1)
296 r.logger.Warn(
302 }()
303
304 > cb(ns, deletedFromDb) registry.go
305 }
306
307 > r.stateChangeCallbacks.Store(key, namespace.StateChangeCallbackFn(callbackWithTiming)) registry.go
308 >
309 > r.nsMapsLock.RLock()
310 > allNamespaces := expmaps.Values(r.idToNamespace)
311 > r.nsMapsLock.RUnlock()
312 >
313 > // call once for each namespace already in the registry
314 > for _, ns := range allNamespaces {
315 callbackWithTiming(ns, false)
316 }