pernamespaceworker.go ×9

Frontier kind: Code frontier

unlabeled · c_9b4987babf23

23 tests · 3106 LOC · 154 files · introduces 0 tests · 23 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges23 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
499 ranges3106 lines · 154 files · Browse complete extent
All tests (intent)
23 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: 23 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/worker/pernamespaceworker.go 23 introduced LOC · 9 ranges

Open complete file

266 }
267
268 > func (w *perNamespaceWorker) getWorkerAllocation(args refreshArgs) (workerAllocation, error) { pernamespaceworker.go
269 > if args.count < 0 {
270 return workerAllocation{}, errInvalidConfiguration
271 > } else if args.count == 0 { pernamespaceworker.go
272 return workerAllocation{0, 0}, nil
273 }
274 > localCount, err := w.getLocallyDesiredWorkers(args) pernamespaceworker.go
275 > if err != nil {
276 return workerAllocation{}, err
277 }
278 > return workerAllocation{total: args.count, local: localCount}, nil pernamespaceworker.go
279 }
280
281 > func (w *perNamespaceWorker) getLocallyDesiredWorkers(args refreshArgs) (int, error) { pernamespaceworker.go
282 > key := args.ns.ID().String()
283 > availableHosts := w.wm.serviceResolver.LookupN(key, args.count)
284 > hostsCount := len(availableHosts)
285 > if hostsCount == 0 {
286 return 0, membership.ErrInsufficientHosts
287 }
288 > maxWorkersPerHost := args.count/hostsCount + 1 pernamespaceworker.go
289 > desiredDistribution := util.RepeatSlice(availableHosts, maxWorkersPerHost)[:args.count]
290 >
291 > isLocal := func(info membership.HostInfo) bool { return info.Identity() == w.wm.self.Identity() }
292 > result := len(util.FilterSlice(desiredDistribution, isLocal))
293 > return result, nil
294 }
295
400 options := cmp.DedicatedWorkerOptions(args.ns)
401 if options.Enabled {
402 > enabledComponents = append(enabledComponents, cmp) pernamespaceworker.go
403 > fmt.Fprintf(&componentSet, "%p,", cmp)
404 > }
405 }
406
411
412 // check if we are responsible for this namespace at all
413 > workerAllocation, err := w.getWorkerAllocation(args) pernamespaceworker.go
414 > if err != nil {
415 w.logger.Error("Failed to look up hosts", tag.Error(err))
416 // TODO: add metric also
417 return err
418 }
419 > if workerAllocation.local == 0 { pernamespaceworker.go
420 // not ours, don't need a worker
421 return errNoWorkerNeeded