reachability.go ×18

Frontier kind: Code frontier

unlabeled · c_cbba90630738

4 tests · 3348 LOC · 148 files · introduces 0 tests · 86 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
20 ranges86 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
565 ranges3348 lines · 148 files · Browse complete extent
All tests (intent)
4 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.

2 files ranked by introduced lines: 86 introduced LOC across 20 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/matching/reachability.go 80 introduced LOC · 18 ranges

Open complete file

91 logger log.Logger,
92 buildId string,
93 > ) (enumspb.BuildIdTaskReachability, error) { reachability.go
94 > reachability, exitPoint, err := rc.run(ctx, buildId)
95 > handler := metrics.GetPerTaskQueueFamilyScope(metricsHandler, rc.nsName.String(), rc.taskQueue, rc.tqConfig.BreakdownMetricsByTaskQueue())
96 > metrics.ReachabilityExitPointCounter.With(handler).Record(1,
97 > metrics.WorkerVersionTag(buildId, rc.tqConfig.BreakdownMetricsByBuildID()),
98 > metrics.StringTag(reachabilityExitPointTagName, reachabilityExitPoint2TagValue[exitPoint]))
99 > logger.Info("Calculated reachability for build id",
100 > tag.WorkerVersion(buildId),
101 > tag.BuildIdTaskReachabilityTag(reachability.String()),
102 > tag.ReachabilityExitPointTag(reachabilityExitPoint2TagValue[exitPoint]),
103 > tag.WorkflowNamespace(rc.nsName.String()),
104 > tag.WorkflowTaskQueueName(rc.taskQueue.Name()),
105 > )
106 > return reachability, err
107 > }
108
109 > func (rc *reachabilityCalculator) run(ctx context.Context, buildId string) (enumspb.BuildIdTaskReachability, reachabilityExitPoint, error) { reachability.go
110 > // 1. Easy UNREACHABLE case
111 > if isActiveRedirectRuleSource(buildId, rc.redirectRules) {
112 return enumspb.BUILD_ID_TASK_REACHABILITY_UNREACHABLE, checkedRuleSourcesForInput, nil
113 }
114
115 // Gather list of all build ids that could point to buildId
116 > buildIdsOfInterest := rc.getBuildIdsOfInterest(buildId, time.Duration(0)) reachability.go
117 >
118 > // 2. Cases for REACHABLE
119 > // 2a. If buildId is assignable to new tasks
120 > if slices.ContainsFunc(buildIdsOfInterest, rc.isReachableActiveAssignmentRuleTargetOrDefault) {
121 return enumspb.BUILD_ID_TASK_REACHABILITY_REACHABLE, checkedRuleTargetsForUpstream, nil
122 }
123
124 // 2b. If buildId could be reached from the backlog
125 > if existsBacklog, err := rc.existsBackloggedActivityOrWFTaskAssignedToAny(ctx, buildIdsOfInterest); err != nil { reachability.go
126 return enumspb.BUILD_ID_TASK_REACHABILITY_UNSPECIFIED, checkedBacklogForUpstream, err
127 > } else if existsBacklog { reachability.go
128 return enumspb.BUILD_ID_TASK_REACHABILITY_REACHABLE, checkedBacklogForUpstream, nil
129 }
132
133 // Gather list of all build ids that could point to buildId, now including deleted rules to account for the delay in updating visibility
134 > buildIdsOfInterest = rc.getBuildIdsOfInterest(buildId, rc.buildIdVisibilityGracePeriod) reachability.go
135 >
136 > // 2c. If buildId is assignable to tasks from open workflows
137 > existsOpenWFAssignedToBuildId, hit, err := rc.existsWFAssignedToAny(ctx, buildIdsOfInterest, true)
138 > if err != nil {
139 return enumspb.BUILD_ID_TASK_REACHABILITY_UNSPECIFIED, checkedOpenWorkflowExecutionsForUpstreamMiss, err
140 }
141 > if existsOpenWFAssignedToBuildId { reachability.go
142 return enumspb.BUILD_ID_TASK_REACHABILITY_REACHABLE, getCacheExitPoint(true, hit), nil
143 }
144
145 // 3. Cases for CLOSED_WORKFLOWS_ONLY
146 > existsClosedWFAssignedToBuildId, hit, err := rc.existsWFAssignedToAny(ctx, buildIdsOfInterest, false) reachability.go
147 > if err != nil {
148 return enumspb.BUILD_ID_TASK_REACHABILITY_UNSPECIFIED, checkedClosedWorkflowExecutionsForUpstreamMiss, err
149 }
150 > if existsClosedWFAssignedToBuildId { reachability.go
151 return enumspb.BUILD_ID_TASK_REACHABILITY_CLOSED_WORKFLOWS_ONLY, getCacheExitPoint(false, hit), nil
152 }
156 }
157
158 > func getCacheExitPoint(open, hit bool) reachabilityExitPoint { reachability.go
159 > if open {
160 if hit {
161 return checkedOpenWorkflowExecutionsForUpstreamHit
163 return checkedOpenWorkflowExecutionsForUpstreamMiss
164 }
165 > if hit { reachability.go
166 > return checkedClosedWorkflowExecutionsForUpstreamHit
167 > }
168 > return checkedClosedWorkflowExecutionsForUpstreamMiss
169 }
170
190 }
191
192 > func (rc *reachabilityCalculator) existsBackloggedActivityOrWFTaskAssignedToAny(ctx context.Context, buildIdsOfInterest []string) (bool, error) { reachability.go
193 > // todo backlog
194 > return false, nil
195 > }
196
197 func (rc *reachabilityCalculator) isReachableActiveAssignmentRuleTargetOrDefault(buildId string) bool {
218 buildIdsOfInterest []string,
219 open bool,
220 > ) (exists, hit bool, err error) { reachability.go
221 > query := rc.makeBuildIdQuery(buildIdsOfInterest, open)
222 > return rc.cache.Get(ctx, *rc.makeBuildIdCountRequest(query), open)
223 > }
224
225 > func (rc *reachabilityCalculator) makeBuildIdCountRequest(query string) *manager.CountWorkflowExecutionsRequest { reachability.go
226 > return &manager.CountWorkflowExecutionsRequest{
227 > NamespaceID: rc.nsID,
228 > Namespace: rc.nsName,
229 > Query: query,
230 > }
231 > }
232
233 func (rc *reachabilityCalculator) makeBuildIdQuery(
314
315 // Get retrieves the Workflow Count existence value based on the query-string key.
316 > func (c *reachabilityCache) Get(ctx context.Context, countRequest manager.CountWorkflowExecutionsRequest, open bool) (exists, hit bool, err error) { reachability.go
317 > // try cache
318 > var result any
319 > if open {
320 > result = c.openWFCache.Get(countRequest)
321 > } else {
322 > result = c.closedWFCache.Get(countRequest)
323 > }
324 > if result != nil {
325 > // there's no reason that the cache would ever contain a non-bool, but just in case, treat non-bool as a miss
326 > exists, ok := result.(bool)
327 > if ok {
328 > return exists, true, nil
329 > }
330 }
331
332 // cache was cold, ask visibility and put result in cache
333 > countResponse, err := c.visibilityMgr.CountWorkflowExecutions(ctx, &countRequest) reachability.go
334 > if err != nil {
335 return false, false, err
336 }
337 > exists = countResponse.Count > 0 reachability.go
338 > c.Put(countRequest, exists, open)
339 > return exists, false, nil
340 }
341
342 // Put adds an element to the cache.
343 > func (c *reachabilityCache) Put(countRequest manager.CountWorkflowExecutionsRequest, exists, open bool) { reachability.go
344 > if open {
345 > c.openWFCache.Put(countRequest, exists)
346 > } else {
347 > c.closedWFCache.Put(countRequest, exists)
348 > }
349 }
go.temporal.io/server/common/log/tag/tags.go 6 introduced LOC · 2 ranges

Open complete file

306
307 // ReachabilityExitPointTag returns tag for reachabilityExitPoint
308 > func ReachabilityExitPointTag(reachabilityExitPoint string) ZapTag { tags.go
309 > return NewStringTag("reachability-exit-point", reachabilityExitPoint)
310 > }
311
312 // BuildIdTaskReachabilityTag returns tag for build id task reachability
313 > func BuildIdTaskReachabilityTag(buildIdReachability string) ZapTag { tags.go
314 > return NewStringTag("build-id-reachability", buildIdReachability)
315 > }
316
317 // size limit