go.temporal.io/server/common/dynamicconfig/registry.go

44 LOC · 16 covered · 28 uncovered · 5 ranges · 22919 concepts · 3 introducers · 11231 tests

File neighbourhood

The centred file is linked to every concept that introduces one of its ranges, every test that runs code from the file, and the gray connector concepts standing between those tests and the file's own introducer concepts. Undirected links join concepts to every file where they introduce source and concepts to the tests they introduce; arrows show specialization between the displayed concepts and bridge only concepts omitted from this view. Concept colors match the source ranges below; connector concepts have no source color and are shown in gray.

Focused file, its introducer and connector concepts, their introduced files, and tests that run code from the file

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 related-file, concept, and source links on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the related-file, concept, and source links on this page while the interactive map is unavailable.

1 package dynamicconfig
2
3 import (
4 "fmt"
5 "sync/atomic"
6 )
7
8 type (
9 registry struct {
10 settings map[Key]GenericSetting
11 queried atomic.Bool
12 }
13 )
14
15 var (
16 globalRegistry registry
17 )
18
19 > func register(s GenericSetting) { setting_gen.go ×51
20 > if globalRegistry.queried.Load() {
21 panic("dynamicconfig.New*Setting must only be called from static initializers")
22 }
23 > if globalRegistry.settings == nil { setting_gen.go ×51
24 > globalRegistry.settings = make(map[Key]GenericSetting)
25 > }
26 > if globalRegistry.settings[s.Key()] != nil {
27 // nolint:forbidigo // only called during static initialization
28 panic(fmt.Sprintf("duplicate registration of dynamic config key: %q", s.Key().String()))
29 }
30 > globalRegistry.settings[s.Key()] = s setting_gen.go ×51
31 }
32
33 > func queryRegistry(k Key) GenericSetting { registry.go ×1
34 > if !globalRegistry.queried.Load() {
35 > globalRegistry.queried.Store(true)
36 > }
37 > return globalRegistry.settings[k]
38 }
39
40 // For testing only; do not call from regular code!
41 > func ResetRegistryForTest() { registry.go ×1
42 > globalRegistry.settings = nil
43 > globalRegistry.queried.Store(false)
44 > }