ownership_based_quota_calculator.go ×6

Frontier kind: Code frontier

unlabeled · c_1ebe468d0b98

14 tests · 3942 LOC · 181 files · introduces 0 tests · 225 LOC · 7 files

Introduces — evidence that enters the hierarchy at this concept

Code
16 ranges225 lines · 7 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
507 ranges3942 lines · 181 files · Browse complete extent
All tests (intent)
14 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.

7 files ranked by introduced lines: 225 introduced LOC across 16 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/queue_factory_base.go 49 introduced LOC · 5 ranges

Open complete file

79 fx.Provide(
80 QueueSchedulerRateLimiterProvider,
81 > func(tqm persistence.HistoryTaskQueueManager) queues.QueueWriter { queue_factory_base.go
82 > return tqm
83 > },
84 queues.NewDLQWriter,
85 fx.Annotated{
129 outboundParams outboundQueueFactoryParams,
130 config *configs.Config,
131 > ) additionalQueueFactories { queue_factory_base.go
132 > factories := []QueueFactory{}
133 > if _, ok := registry.GetCategoryByID(tasks.CategoryIDArchival); ok {
134 factories = append(factories, NewArchivalQueueFactory(archivalParams))
135 }
136 > factories = append(factories, NewOutboundQueueFactory(outboundParams)) queue_factory_base.go
137 > return additionalQueueFactories{
138 > Factories: factories,
139 > }
140 }
141
146 timeSource clock.TimeSource,
147 logger log.SnTaggedLogger,
148 > ) (queues.SchedulerRateLimiter, error) { queue_factory_base.go
149 > return queues.NewPrioritySchedulerRateLimiter(
150 > calculator.NewLoggedNamespaceCalculator(
151 > shard.NewOwnershipAwareNamespaceQuotaCalculator(
152 > ownershipBasedQuotaScaler,
153 > serviceResolver,
154 > config.TaskSchedulerNamespaceMaxQPS,
155 > config.TaskSchedulerGlobalNamespaceMaxQPS,
156 > ),
157 > log.With(logger, tag.ComponentTaskScheduler, tag.ScopeNamespace),
158 > ).GetQuota,
159 > calculator.NewLoggedCalculator(
160 > shard.NewOwnershipAwareQuotaCalculator(
161 > ownershipBasedQuotaScaler,
162 > serviceResolver,
163 > config.TaskSchedulerMaxQPS,
164 > config.TaskSchedulerGlobalMaxQPS,
165 > ),
166 > log.With(logger, tag.ComponentTaskScheduler, tag.ScopeHost),
167 > ).GetQuota,
168 > // TODO: reuse persistence rate limit calculator in PersistenceRateLimitingParamsProvider
169 > shard.NewOwnershipAwareNamespaceQuotaCalculator(
170 > ownershipBasedQuotaScaler,
171 > serviceResolver,
172 > config.PersistenceNamespaceMaxQPS,
173 > config.PersistenceGlobalNamespaceMaxQPS,
174 > ).GetQuota,
175 > shard.NewOwnershipAwareQuotaCalculator(
176 > ownershipBasedQuotaScaler,
177 > serviceResolver,
178 > config.PersistenceMaxQPS,
179 > config.PersistenceGlobalMaxQPS,
180 > ).GetQuota,
181 > )
182 > }
183
184 func QueueFactoryLifetimeHooks(
185 params QueueFactoriesLifetimeHookParams,
187 > params.Lifecycle.Append(
188 > fx.Hook{
189 > OnStart: func(context.Context) error {
190 for _, factory := range params.Factories {
191 factory.Start()
go.temporal.io/server/service/history/timer_queue_factory.go 39 introduced LOC · 1 range

Open complete file

39 func NewTimerQueueFactory(
40 params timerQueueFactoryParams,
41 > ) QueueFactory { timer_queue_factory.go
42 > return &timerQueueFactory{
43 > timerQueueFactoryParams: params,
44 > QueueFactoryBase: QueueFactoryBase{
45 > HostScheduler: queues.NewScheduler(
46 > params.ClusterMetadata.GetCurrentClusterName(),
47 > queues.SchedulerOptions{
48 > WorkerCount: params.Config.TimerProcessorSchedulerWorkerCount,
49 > ActiveNamespaceWeights: params.Config.TimerProcessorSchedulerActiveRoundRobinWeights,
50 > StandbyNamespaceWeights: params.Config.TimerProcessorSchedulerStandbyRoundRobinWeights,
51 > InactiveNamespaceDeletionDelay: params.Config.TaskSchedulerInactiveChannelDeletionDelay,
52 > ExecutionAwareSchedulerOptions: ctasks.ExecutionAwareSchedulerOptions{
53 > Enabled: params.Config.TaskSchedulerEnableExecutionQueueScheduler,
54 > MaxQueues: params.Config.TaskSchedulerExecutionQueueSchedulerMaxQueues,
55 > QueueTTL: params.Config.TaskSchedulerExecutionQueueSchedulerQueueTTL,
56 > QueueConcurrency: params.Config.TaskSchedulerExecutionQueueSchedulerQueueConcurrency,
57 > },
58 > },
59 > params.NamespaceRegistry,
60 > params.Logger,
61 > params.MetricsHandler,
62 > params.TimeSource,
63 > ),
64 > HostPriorityAssigner: queues.NewPriorityAssigner(
65 > params.NamespaceRegistry,
66 > params.ClusterMetadata.GetCurrentClusterName(),
67 > ),
68 > HostReaderRateLimiter: queues.NewReaderPriorityRateLimiter(
69 > NewHostRateLimiterRateFn(
70 > params.Config.TimerProcessorMaxPollHostRPS,
71 > params.Config.PersistenceMaxQPS,
72 > timerQueuePersistenceMaxRPSRatio,
73 > ),
74 > int64(params.Config.TimerQueueMaxReaderCount()),
75 > ),
76 > Tracer: params.TracerProvider.Tracer(telemetry.ComponentQueueTimer),
77 > },
78 > }
79 > }
80
81 func (f *timerQueueFactory) CreateQueue(
go.temporal.io/server/service/history/transfer_queue_factory.go 39 introduced LOC · 1 range

Open complete file

46 func NewTransferQueueFactory(
47 params transferQueueFactoryParams,
48 > ) QueueFactory { transfer_queue_factory.go
49 > return &transferQueueFactory{
50 > transferQueueFactoryParams: params,
51 > QueueFactoryBase: QueueFactoryBase{
52 > HostScheduler: queues.NewScheduler(
53 > params.ClusterMetadata.GetCurrentClusterName(),
54 > queues.SchedulerOptions{
55 > WorkerCount: params.Config.TransferProcessorSchedulerWorkerCount,
56 > ActiveNamespaceWeights: params.Config.TransferProcessorSchedulerActiveRoundRobinWeights,
57 > StandbyNamespaceWeights: params.Config.TransferProcessorSchedulerStandbyRoundRobinWeights,
58 > InactiveNamespaceDeletionDelay: params.Config.TaskSchedulerInactiveChannelDeletionDelay,
59 > ExecutionAwareSchedulerOptions: ctasks.ExecutionAwareSchedulerOptions{
60 > Enabled: params.Config.TaskSchedulerEnableExecutionQueueScheduler,
61 > MaxQueues: params.Config.TaskSchedulerExecutionQueueSchedulerMaxQueues,
62 > QueueTTL: params.Config.TaskSchedulerExecutionQueueSchedulerQueueTTL,
63 > QueueConcurrency: params.Config.TaskSchedulerExecutionQueueSchedulerQueueConcurrency,
64 > },
65 > },
66 > params.NamespaceRegistry,
67 > params.Logger,
68 > params.MetricsHandler,
69 > params.TimeSource,
70 > ),
71 > HostPriorityAssigner: queues.NewPriorityAssigner(
72 > params.NamespaceRegistry,
73 > params.ClusterMetadata.GetCurrentClusterName(),
74 > ),
75 > HostReaderRateLimiter: queues.NewReaderPriorityRateLimiter(
76 > NewHostRateLimiterRateFn(
77 > params.Config.TransferProcessorMaxPollHostRPS,
78 > params.Config.PersistenceMaxQPS,
79 > transferQueuePersistenceMaxRPSRatio,
80 > ),
81 > int64(params.Config.TransferQueueMaxReaderCount()),
82 > ),
83 > Tracer: params.TracerProvider.Tracer(telemetry.ComponentQueueTransfer),
84 > },
85 > }
86 > }
87
88 func (f *transferQueueFactory) CreateQueue(
go.temporal.io/server/service/history/visibility_queue_factory.go 39 introduced LOC · 1 range

Open complete file

35 func NewVisibilityQueueFactory(
36 params visibilityQueueFactoryParams,
37 > ) QueueFactory { visibility_queue_factory.go
38 > return &visibilityQueueFactory{
39 > visibilityQueueFactoryParams: params,
40 > QueueFactoryBase: QueueFactoryBase{
41 > HostScheduler: queues.NewScheduler(
42 > params.ClusterMetadata.GetCurrentClusterName(),
43 > queues.SchedulerOptions{
44 > WorkerCount: params.Config.VisibilityProcessorSchedulerWorkerCount,
45 > ActiveNamespaceWeights: params.Config.VisibilityProcessorSchedulerActiveRoundRobinWeights,
46 > StandbyNamespaceWeights: params.Config.VisibilityProcessorSchedulerStandbyRoundRobinWeights,
47 > InactiveNamespaceDeletionDelay: params.Config.TaskSchedulerInactiveChannelDeletionDelay,
48 > ExecutionAwareSchedulerOptions: ctasks.ExecutionAwareSchedulerOptions{
49 > Enabled: params.Config.TaskSchedulerEnableExecutionQueueScheduler,
50 > MaxQueues: params.Config.TaskSchedulerExecutionQueueSchedulerMaxQueues,
51 > QueueTTL: params.Config.TaskSchedulerExecutionQueueSchedulerQueueTTL,
52 > QueueConcurrency: params.Config.TaskSchedulerExecutionQueueSchedulerQueueConcurrency,
53 > },
54 > },
55 > params.NamespaceRegistry,
56 > params.Logger,
57 > params.MetricsHandler,
58 > params.TimeSource,
59 > ),
60 > HostPriorityAssigner: queues.NewPriorityAssigner(
61 > params.NamespaceRegistry,
62 > params.ClusterMetadata.GetCurrentClusterName(),
63 > ),
64 > HostReaderRateLimiter: queues.NewReaderPriorityRateLimiter(
65 > NewHostRateLimiterRateFn(
66 > params.Config.VisibilityProcessorMaxPollHostRPS,
67 > params.Config.PersistenceMaxQPS,
68 > visibilityQueuePersistenceMaxRPSRatio,
69 > ),
70 > int64(params.Config.VisibilityQueueMaxReaderCount()),
71 > ),
72 > Tracer: params.TracerProvider.Tracer(telemetry.ComponentQueueVisibility),
73 > },
74 > }
75 > }
76
77 func (f *visibilityQueueFactory) CreateQueue(
go.temporal.io/server/service/history/memory_scheduled_queue_factory.go 29 introduced LOC · 1 range

Open complete file

55 func NewMemoryScheduledQueueFactory(
56 params memoryScheduledQueueFactoryParams,
57 > ) QueueFactory { memory_scheduled_queue_factory.go
58 > logger := log.With(params.Logger, tag.ComponentMemoryScheduledQueue)
59 > metricsHandler := params.MetricsHandler.WithTags(metrics.OperationTag(metrics.OperationMemoryScheduledQueueProcessorScope))
60 >
61 > hostScheduler := ctasks.NewFIFOScheduler[ctasks.Task](
62 > &ctasks.FIFOSchedulerOptions{
63 > QueueSize: 0, // Don't buffer tasks in scheduler. If all workers are busy memoryScheduledQueue reschedules tasks into itself.
64 > WorkerCount: params.Config.MemoryTimerProcessorSchedulerWorkerCount,
65 > },
66 > logger,
67 > )
68 >
69 > return &memoryScheduledQueueFactory{
70 > scheduler: hostScheduler,
71 > priorityAssigner: queues.NewPriorityAssigner(
72 > params.NamespaceRegistry,
73 > params.ClusterMetadata.GetCurrentClusterName(),
74 > ),
75 > namespaceRegistry: params.NamespaceRegistry,
76 > clusterMetadata: params.ClusterMetadata,
77 > workflowCache: params.WorkflowCache,
78 > timeSource: params.TimeSource,
79 > chasmRegistry: params.ChasmRegistry,
80 > metricsHandler: metricsHandler,
81 > tracer: params.TracerProvider.Tracer(telemetry.ComponentQueueMemory),
82 > logger: logger,
83 > executorWrapper: params.ExecutorWrapper,
84 > }
85 > }
86
87 func (f *memoryScheduledQueueFactory) Start() {
go.temporal.io/server/service/history/shard/ownership_based_quota_calculator.go 26 introduced LOC · 6 ranges

Open complete file

24 perInstanceQuota func() int,
25 globalQuota func() int,
26 > ) *OwnershipAwareQuotaCalculator { ownership_based_quota_calculator.go
27 > return &OwnershipAwareQuotaCalculator{
28 > ClusterAwareQuotaCalculator: calculator.ClusterAwareQuotaCalculator{
29 > MemberCounter: memberCounter,
30 > PerInstanceQuota: perInstanceQuota,
31 > GlobalQuota: globalQuota,
32 > },
33 > scaler: scaler,
34 > }
35 > }
36
37 > func (c *OwnershipAwareQuotaCalculator) GetQuota() float64 { ownership_based_quota_calculator.go
38 > if quota, ok := getOwnershipScaledQuota(c.scaler, c.GlobalQuota()); ok {
39 return quota
40 }
41 > return c.ClusterAwareQuotaCalculator.GetQuota() ownership_based_quota_calculator.go
42 }
43
47 perInstanceQuota func(namespace string) int,
48 globalQuota func(namespace string) int,
49 > ) *OwnershipAwareNamespaceQuotaCalculator { ownership_based_quota_calculator.go
50 > return &OwnershipAwareNamespaceQuotaCalculator{
51 > ClusterAwareNamespaceQuotaCalculator: calculator.ClusterAwareNamespaceQuotaCalculator{
52 > MemberCounter: memberCounter,
53 > PerInstanceQuota: perInstanceQuota,
54 > GlobalQuota: globalQuota,
55 > },
56 > scaler: scaler,
57 > }
58 > }
59
60 func (c *OwnershipAwareNamespaceQuotaCalculator) GetQuota(namespace string) float64 {
go.temporal.io/server/service/history/circuitbreakerpool/fx.go 4 introduced LOC · 1 range

Open complete file

22 namespaceRegistry namespace.Registry,
23 config *configs.Config,
24 > ) *OutboundQueueCircuitBreakerPool { fx.go
25 > return &OutboundQueueCircuitBreakerPool{
26 > CircuitBreakerPool: NewCircuitBreakerPool(
27 > func(key tasks.TaskGroupNamespaceIDAndDestination) circuitbreaker.TwoStepCircuitBreaker {
28 // This is intentionally not failing the function in case of error. The circuit breaker is
29 // agnostic to Task implementation, and thus the settings function is not expected to return