task_queue_partition_manager.go ×14

Frontier kind: Code frontier

unlabeled · c_5b70b049a0f6

406 tests · 4010 LOC · 171 files · introduces 0 tests · 70 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
17 ranges70 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
689 ranges4010 lines · 171 files · Browse complete extent
All tests (intent)
406 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.

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

go.temporal.io/server/service/matching/task_queue_partition_manager.go 60 introduced LOC · 14 ranges

Open complete file

208 // computeEffectiveConfig determines the effective NewMatcher and EnableFairness config values
209 // based on fairnessState, autoEnable, and the base dynamic config values.
210 > func (pm *taskQueuePartitionManagerImpl) computeEffectiveConfig(autoEnable, fairness, newMatcher bool) (effectiveNewMatcher, effectiveEnableFairness bool) { task_queue_partition_manager.go
211 > effectiveEnableFairness = fairness && pm.partition.SupportsFairness()
212 > effectiveNewMatcher = newMatcher || fairness
213 > if !autoEnable {
214 return
215 }
233 }
234
235 > func (pm *taskQueuePartitionManagerImpl) initialize() (retErr error) { task_queue_partition_manager.go
236 > defer pm.initCancel()
237 > defer func() { pm.defaultQueueFuture.SetIfNotReady(nil, retErr) }()
238
239 > err := pm.userDataManager.WaitUntilInitialized(pm.initCtx) task_queue_partition_manager.go
240 > if err != nil {
241 return err
242 }
243 > data, _, err := pm.getPerTypeUserData() task_queue_partition_manager.go
244 > if err != nil {
245 return err
246 }
247
248 > pm.fairnessState = data.GetFairnessState() task_queue_partition_manager.go
249 > changeKey := pm.partition.GradualChangeKey()
250 >
251 > var autoEnable, fairness, newMatcher bool
252 > autoEnable, pm.cancelAutoEnableSub = pm.config.AutoEnableV2Sub(pm.autoEnableChanged)
253 >
254 > unloadOnBaseConfigChange := func(bool) {
255 if pm.fairnessState == enumsspb.FAIRNESS_STATE_UNSPECIFIED || !pm.config.AutoEnableV2() {
256 pm.unloadFromEngine(unloadCauseConfigChange)
258 }
259
260 > newMatcher, pm.cancelNewMatcherSub = dynamicconfig.SubscribeGradualChange( task_queue_partition_manager.go
261 > pm.config.NewMatcherSub, changeKey, unloadOnBaseConfigChange, pm.engine.timeSource)
262 > fairness, pm.cancelFairnessSub = dynamicconfig.SubscribeGradualChange(
263 > pm.config.EnableFairnessSub, changeKey, unloadOnBaseConfigChange, pm.engine.timeSource)
264 >
265 > // Determine initial config values
266 > pm.config.NewMatcher, pm.config.EnableFairness = pm.computeEffectiveConfig(autoEnable, fairness, newMatcher)
267 >
268 > defaultQ, err := newPhysicalTaskQueueManager(pm, UnversionedQueueKey(pm.partition))
269 > if err != nil {
270 return err
271 }
272 > pm.defaultQueueFuture.Set(defaultQ, nil) task_queue_partition_manager.go
273 > defaultQ.Start()
274 > pm.goroGroup.Go(pm.updateEphemeralData)
275 > pm.goroGroup.Go(pm.emitLogicalBacklogMetrics)
276 >
277 > // Whenever a root partition is loaded, we need to force all child partitions to load.
278 > // If there is a backlog of tasks on any child partitions, force loading will ensure
279 > // that they can forward their tasks the poller which caused the root partition to be
280 > // loaded. We're in a separate goroutine in initialize() so we can do it here.
281 > if defaultQ.WaitUntilInitialized(pm.initCtx) == nil {
282 > pm.ForceLoadAllChildPartitions()
283 > }
284
286 }
287
294 }
295
296 > func (pm *taskQueuePartitionManagerImpl) Start() { task_queue_partition_manager.go
297 > pm.loadTime = time.Now()
298 > pm.engine.updateTaskQueuePartitionGauge(pm.Namespace(), pm.partition, 1)
299 > pm.rateLimitManager.Start()
300 > pm.userDataManager.Start()
301 > for _, hook := range pm.taskHooks {
302 hook.Start()
303 }
304
305 //nolint:errcheck
306 > go pm.initialize() task_queue_partition_manager.go
307 }
308
1499 }
1500
1501 > func (pm *taskQueuePartitionManagerImpl) updateEphemeralData(ctx context.Context) error { task_queue_partition_manager.go
1502 > // for now, this only applies to normal workflow task queues, only with new matcher
1503 > if pm.partition.Kind() != enumspb.TASK_QUEUE_KIND_NORMAL ||
1504 > pm.partition.TaskType() != enumspb.TASK_QUEUE_TYPE_WORKFLOW ||
1505 > !pm.config.NewMatcher {
1506 return nil
1507 }
1565 }
1566
1567 > func (pm *taskQueuePartitionManagerImpl) emitLogicalBacklogMetrics(ctx context.Context) error { task_queue_partition_manager.go
1568 > for {
1569 > interval := pm.config.BacklogMetricsEmitInterval()
1570 > if interval == 0 { // disabled
1571 _ = util.InterruptibleSleep(ctx, time.Minute)
1572 if ctx.Err() != nil {
1898 // ForceLoadAllChildPartitions force-loads known child (read) partitions in new goroutines.
1899 // TODO(dp): consider moving this into scaleManager.backgroundWork after auto-scaling is enabled everywhere.
1900 > func (pm *taskQueuePartitionManagerImpl) ForceLoadAllChildPartitions() { task_queue_partition_manager.go
1901 > if !pm.partition.IsRoot() {
1902 return
1903 }
go.temporal.io/server/service/matching/config.go 8 introduced LOC · 2 ranges

Open complete file

414 RangeSize: config.RangeSize,
415 NewMatcherSub: func(cb func(dynamicconfig.GradualChange[bool])) (dynamicconfig.GradualChange[bool], func()) {
416 > return config.NewMatcherSub(ns.String(), taskQueueName, taskType, cb) config.go
417 > },
418 > EnableFairnessSub: func(cb func(dynamicconfig.GradualChange[bool])) (dynamicconfig.GradualChange[bool], func()) {
419 > return config.EnableFairnessSub(ns.String(), taskQueueName, taskType, cb)
420 > },
421 EnableMigration: func() bool {
422 return config.EnableMigration(ns.String(), taskQueueName, taskType)
426 return v
427 },
428 > AutoEnableV2Sub: func(cb func(bool)) (bool, func()) { config.go
429 > return config.AutoEnableV2Sub(ns.String(), taskQueueName, taskType, cb)
430 > },
431 GetTasksBatchSize: func() int {
432 return config.GetTasksBatchSize(ns.String(), taskQueueName, taskType)
go.temporal.io/server/api/persistence/v1/task_queues.pb.go 2 introduced LOC · 1 range

Open complete file

636 }
637
638 > func (x *TaskQueueTypeUserData) GetFairnessState() v14.FairnessState { task_queues.pb.go
639 > if x != nil {
640 return x.FairnessState
641 }