task_queue_partition_manager.go ×5

Frontier kind: Code frontier

unlabeled · c_a340037d31dd

469 tests · 3305 LOC · 162 files · introduces 0 tests · 104 LOC · 5 files

Introduces — evidence that enters the hierarchy at this concept

Code
15 ranges104 lines · 5 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
525 ranges3305 lines · 162 files · Browse complete extent
All tests (intent)
469 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.

5 files ranked by introduced lines: 104 introduced LOC across 15 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/matching/physical_task_queue_manager.go 55 introduced LOC · 3 ranges

Open complete file

130 partitionMgr *taskQueuePartitionManagerImpl,
131 queue *PhysicalTaskQueueKey,
132 > ) (*physicalTaskQueueManagerImpl, error) { physical_task_queue_manager.go
133 > e := partitionMgr.engine
134 > config := partitionMgr.config
135 > versionTagValue := queue.Version().MetricsTagValue()
136 > buildIDTag := tag.WorkerVersion(versionTagValue)
137 > taggedMetricsHandler := partitionMgr.metricsHandler.WithTags(
138 > metrics.OperationTag(metrics.MatchingTaskQueueMgrScope),
139 > metrics.WorkerVersionTag(versionTagValue, config.BreakdownMetricsByBuildID()),
140 > metrics.WorkerDeploymentNameTag(queue.Version().Deployment().GetSeriesName(), config.BreakdownMetricsByBuildID()),
141 > metrics.WorkerDeploymentBuildIDTag(queue.Version().Deployment().GetBuildId(), config.BreakdownMetricsByBuildID()),
142 > )
143 >
144 > tqCtx, tqCancel := context.WithCancel(partitionMgr.callerInfoContext(context.Background()))
145 >
146 > // We multiply by a big number so that we can later divide it by the number of pollers when grabbing permits,
147 > // to allow us to make more decisions per second when there are more pollers.
148 > pollerScalingRateLimitFn := func() float64 {
149 > return config.PollerScalingDecisionsPerSecond() * 1e6
150 > }
151 > pqMgr := &physicalTaskQueueManagerImpl{
152 > status: common.DaemonStatusInitialized,
153 > partitionMgr: partitionMgr,
154 > queue: queue,
155 > config: config,
156 > tqCtx: tqCtx,
157 > tqCtxCancel: tqCancel,
158 > namespaceRegistry: e.namespaceRegistry,
159 > matchingClient: e.matchingRawClient,
160 > clusterMeta: e.clusterMeta,
161 > metricsHandler: taggedMetricsHandler,
162 > tasksAdded: make(map[priorityKey]*taskTracker),
163 > tasksDispatched: make(map[priorityKey]*taskTracker),
164 > tasksRateLimited: e.newTaskTracker(),
165 > pollerScalingRateLimiter: quotas.NewDefaultOutgoingRateLimiter(pollerScalingRateLimitFn),
166 > deploymentRegistrationCh: make(chan struct{}, 1),
167 > }
168 > pqMgr.deploymentRegistrationCh <- struct{}{} // seed
169 >
170 > pqMgr.pollerHistory = newPollerHistory(partitionMgr.config.PollerHistoryTTL())
171 >
172 > pqMgr.liveness = newLiveness(
173 > clock.NewRealTimeSource(),
174 > config.MaxTaskQueueIdleTime,
175 > func() { pqMgr.UnloadFromPartitionManager(unloadCauseIdle) },
176 )
177
178 > pqMgr.taskValidator = newTaskValidator( physical_task_queue_manager.go
179 > tqCtx,
180 > pqMgr.clusterMeta,
181 > pqMgr.namespaceRegistry,
182 > pqMgr.partitionMgr.engine.historyClient,
183 > )
184 >
185 > switch {
186 case config.EnableFairness:
187 pqMgr.logger = log.With(partitionMgr.logger, buildIDTag, backlogTagFairness)
865 }
866
867 > func (c *physicalTaskQueueManagerImpl) QueueKey() *PhysicalTaskQueueKey { physical_task_queue_manager.go
868 > return c.queue
869 > }
870
871 func (c *physicalTaskQueueManagerImpl) UnloadFromPartitionManager(unloadCause unloadCause) {
go.temporal.io/server/service/matching/task_queue_partition_manager.go 34 introduced LOC · 5 ranges

Open complete file

135 metricsHandler metrics.Handler,
136 userDataManager userDataManager,
137 > ) (*taskQueuePartitionManagerImpl, error) { task_queue_partition_manager.go
138 > rateLimitManager := newRateLimitManager(
139 > userDataManager,
140 > tqConfig,
141 > partition.TaskQueue().TaskType())
142 >
143 > var taskHooks []hooks.TaskHook
144 > for _, hookFactory := range e.taskHookFactories {
145 taskHook := hookFactory.Create(&hooks.TaskHookFactoryCreateDetails{
146 Namespace: ns,
153
154 // create partition scaler + manager if root
155 > var scaleManager *scaleManager task_queue_partition_manager.go
156 > if partition.IsRoot() && e.partitionScalerFactory != nil {
157 partitionScaler := e.partitionScalerFactory.New(
158 ns.Name(),
178 }
179
180 > pm := &taskQueuePartitionManagerImpl{ task_queue_partition_manager.go
181 > engine: e,
182 > partition: partition,
183 > ns: ns,
184 > config: tqConfig,
185 > logger: logger,
186 > throttledLogger: throttledLogger,
187 > matchingClient: e.matchingRawClient,
188 > metricsHandler: metricsHandler,
189 > versionedQueues: make(map[PhysicalTaskQueueVersion]physicalTaskQueueManager),
190 > userDataManager: userDataManager,
191 > rateLimitManager: rateLimitManager,
192 > scaleManager: scaleManager,
193 > defaultQueueFuture: future.NewFuture[physicalTaskQueueManager](),
194 > autoEnableRateLimiter: quotas.NewRateLimiter(1.0/60, 1),
195 > taskHooks: taskHooks,
196 > }
197 > pm.initCtx, pm.initCancel = context.WithCancel(context.Background())
198 >
199 > if pm.partition.IsRoot() {
200 pm.cache = cache.New(10000, &cache.Options{
201 TTL: max(1, tqConfig.TaskQueueInfoByBuildIdTTL())}, // ensure TTL is never zero (which would disable TTL)
1892 }
1893
1894 > func (pm *taskQueuePartitionManagerImpl) callerInfoContext(ctx context.Context) context.Context { task_queue_partition_manager.go
1895 > return headers.SetCallerInfo(ctx, headers.NewBackgroundHighCallerInfo(pm.ns.Name().String()))
1896 > }
1897
1898 // ForceLoadAllChildPartitions force-loads known child (read) partitions in new goroutines.
go.temporal.io/server/common/metrics/tags.go 6 introduced LOC · 4 ranges

Open complete file

198 }
199
200 > func WorkerDeploymentNameTag(deploymentName string, versionBreakdown bool) Tag { tags.go
201 > if !versionBreakdown {
202 deploymentName = ""
203 }
204 > return Tag{Key: workerDeploymentName, Value: deploymentName} tags.go
205 }
206
207 > func WorkerDeploymentBuildIDTag(buildID string, versionBreakdown bool) Tag { tags.go
208 > if !versionBreakdown {
209 buildID = ""
210 }
211 > return Tag{Key: workerDeploymentBuildID, Value: buildID} tags.go
212 }
213
go.temporal.io/server/service/matching/config.go 6 introduced LOC · 2 ranges

Open complete file

559 return config.MaxFairnessKeyWeightOverrides(ns.String(), taskQueueName, taskType)
560 },
561 > PollerHistoryTTL: func() time.Duration { config.go
562 > return config.PollerHistoryTTL(ns.String())
563 > },
564 PollerScalingBacklogAgeScaleUp: func() time.Duration {
565 return config.PollerScalingBacklogAgeScaleUp(ns.String(), taskQueueName, taskType)
568 return config.PollerScalingWaitTime(ns.String(), taskQueueName, taskType)
569 },
570 > PollerScalingDecisionsPerSecond: func() float64 { config.go
571 > return config.PollerScalingDecisionsPerSecond(ns.String(), taskQueueName, taskType)
572 > },
573 PollerScalingTaskAddToDispatchRatio: func() float64 {
574 return config.PollerScalingTaskAddToDispatchRatio(ns.String(), taskQueueName, taskType)
go.temporal.io/server/service/matching/matching_engine.go 3 introduced LOC · 1 range

Open complete file

3816 }
3817
3818 > func (e *matchingEngineImpl) newTaskTracker() *taskTracker { matching_engine.go
3819 > return newTaskTracker(e.timeSource, 5*time.Second, 30*time.Second)
3820 > }
3821
3822 // migrateOldFormatVersions moves versions present in the given deployment from the