endpoint_registry.go ×4

Frontier kind: Code frontier

unlabeled · c_a97355684b0e

17 tests · 2055 LOC · 86 files · introduces 0 tests · 37 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
4 ranges37 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
300 ranges2055 lines · 86 files · Browse complete extent
All tests (intent)
17 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: 37 introduced LOC across 4 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/common/nexus/endpoint_registry.go 37 introduced LOC · 4 ranges

Open complete file

109 // StartLifecycle starts this component. It should only be invoked by an fx lifecycle hook.
110 // Should not be called multiple times or concurrently with StopLifecycle()
111 > func (r *EndpointRegistryImpl) StartLifecycle() { endpoint_registry.go
112 > r.setEnabled(true)
113 > }
114
115 // StopLifecycle stops this component. It should only be invoked by an fx lifecycle hook.
119 }
120
121 > func (r *EndpointRegistryImpl) setEnabled(enabled bool) { endpoint_registry.go
122 > oldReady := r.dataReady.Load()
123 > if oldReady == nil && enabled {
124 > backgroundCtx := headers.SetCallerInfo(
125 > context.Background(),
126 > headers.SystemBackgroundHighCallerInfo,
127 > )
128 > newReady := &dataReady{
129 > refresh: goro.NewHandle(backgroundCtx),
130 > ready: make(chan struct{}),
131 > }
132 > if r.dataReady.CompareAndSwap(oldReady, newReady) {
133 > newReady.refresh.Go(func(ctx context.Context) error {
134 > return r.refreshEndpointsLoop(ctx, newReady)
135 > })
136 }
137 } else if oldReady != nil && !enabled {
222 }
223
224 > func (r *EndpointRegistryImpl) refreshEndpointsLoop(ctx context.Context, dataReady *dataReady) error { endpoint_registry.go
225 > hasLoadedEndpointData := false
226 >
227 > for ctx.Err() == nil {
228 > start := time.Now()
229 > enforceMinWait := true
230 > if !hasLoadedEndpointData {
231 > // Loading endpoints for the first time after being (re)enabled, so load with fallback to persistence
232 > // and unblock any threads waiting on r.dataReady if successful.
233 > err := backoff.ThrottleRetryContext(ctx, r.loadEndpoints, r.config.refreshRetryPolicy, nil)
234 > if err == nil {
235 hasLoadedEndpointData = true
236 enforceMinWait = false
253 r.dataLock.Unlock()
254 }
255 > elapsed := time.Since(start) endpoint_registry.go
256 >
257 > minWaitTime := r.config.refreshMinWait()
258 > // In general, we want to start a new call immediately on completion of the previous one. But if the remote is
259 > // broken and returns success immediately, we might end up spinning. So enforce a minimum wait time that
260 > // increases as long as we keep getting very fast replies. Only enforce the min wait if the remote does not
261 > // return new data.
262 > if enforceMinWait && elapsed < minWaitTime {
263 util.InterruptibleSleep(ctx, minWaitTime-elapsed)
264 }