81
func (f *timerQueueFactory) CreateQueue(
82
shardContext historyi.ShardContext,
84
>
logger := log.With(shardContext.GetLogger(), tag.ComponentTimerQueue)
85
>
metricsHandler := f.MetricsHandler.WithTags(metrics.OperationTag(metrics.OperationTimerQueueProcessorScope))
86
>
87
>
currentClusterName := f.ClusterMetadata.GetCurrentClusterName()
88
>
workflowDeleteManager := deletemanager.NewDeleteManager(
89
>
shardContext,
90
>
f.WorkflowCache,
91
>
f.Config,
92
>
shardContext.GetTimeSource(),
93
>
f.VisibilityManager,
94
>
)
95
>
96
>
shardScheduler := queues.NewRateLimitedScheduler(
97
>
f.HostScheduler,
98
>
queues.RateLimitedSchedulerOptions{
99
>
Enabled: f.Config.TaskSchedulerEnableRateLimiter,
100
>
EnableShadowMode: f.Config.TaskSchedulerEnableRateLimiterShadowMode,
101
>
StartupDelay: f.Config.TaskSchedulerRateLimiterStartupDelay,
102
>
},
103
>
currentClusterName,
104
>
f.NamespaceRegistry,
105
>
f.SchedulerRateLimiter,
106
>
f.TimeSource,
107
>
f.ChasmRegistry,
108
>
logger,
109
>
metricsHandler,
110
>
)
111
>
112
>
rescheduler := queues.NewRescheduler(
113
>
shardScheduler,
114
>
shardContext.GetTimeSource(),
115
>
logger,
116
>
metricsHandler,
117
>
)
118
>
119
>
activeExecutor := newTimerQueueActiveTaskExecutor(
120
>
shardContext,
121
>
f.WorkflowCache,
122
>
workflowDeleteManager,
123
>
logger,
124
>
f.MetricsHandler,
125
>
f.Config,
126
>
f.MatchingRawClient,
127
>
f.ChasmEngine,
128
>
)
129
>
130
>
standbyExecutor := newTimerQueueStandbyTaskExecutor(
131
>
shardContext,
132
>
f.WorkflowCache,
133
>
workflowDeleteManager,
134
>
f.MatchingRawClient,
135
>
f.ChasmEngine,
136
>
logger,
137
>
f.MetricsHandler,
138
>
// note: the cluster name is for calculating time for standby tasks,
139
>
// here we are basically using current cluster time
140
>
// this field will be deprecated soon, currently exists so that
141
>
// we have the option of revert to old behavior
142
>
currentClusterName,
143
>
f.Config,
144
>
f.ClientBean,
145
>
)
146
>
147
>
executor := queues.NewActiveStandbyExecutor(
148
>
currentClusterName,
149
>
f.NamespaceRegistry,
150
>
activeExecutor,
151
>
standbyExecutor,
152
>
logger,
153
>
)
154
>
if f.ExecutorWrapper != nil {
155
executor = f.ExecutorWrapper.Wrap(executor)
156
}
157
159
>
executor,
160
>
shardScheduler,
161
>
rescheduler,
162
>
f.HostPriorityAssigner,
163
>
shardContext.GetTimeSource(),
164
>
shardContext.GetNamespaceRegistry(),
165
>
shardContext.GetClusterMetadata(),
166
>
f.ChasmRegistry,
167
>
queues.GetTaskTypeTagValue,
168
>
logger,
169
>
metricsHandler,
170
>
f.Tracer,
171
>
f.DLQWriter,
172
>
f.Config.TaskDLQEnabled,
173
>
f.Config.TaskDLQUnexpectedErrorAttempts,
174
>
f.Config.TaskDLQInternalErrors,
175
>
f.Config.TaskDLQErrorPattern,
176
>
)
177
>
return queues.NewScheduledQueue(
178
>
shardContext,
179
>
tasks.CategoryTimer,
180
>
shardScheduler,
181
>
rescheduler,
182
>
factory,
183
>
&queues.Options{
184
>
ReaderOptions: queues.ReaderOptions{
185
>
BatchSize: f.Config.TimerTaskBatchSize,
186
>
MaxPendingTasksCount: f.Config.QueuePendingTaskMaxCount,
187
>
PollBackoffInterval: f.Config.TimerProcessorPollBackoffInterval,
188
>
MaxPredicateSize: f.Config.QueueMaxPredicateSize,
189
>
},
190
>
MonitorOptions: queues.MonitorOptions{
191
>
PendingTasksCriticalCount: f.Config.QueuePendingTaskCriticalCount,
192
>
ReaderStuckCriticalAttempts: f.Config.QueueReaderStuckCriticalAttempts,
193
>
SliceCountCriticalThreshold: f.Config.QueueCriticalSlicesCount,
194
>
},
195
>
MaxPollRPS: f.Config.TimerProcessorMaxPollRPS,
196
>
MaxPollInterval: f.Config.TimerProcessorMaxPollInterval,
197
>
MaxPollIntervalJitterCoefficient: f.Config.TimerProcessorMaxPollIntervalJitterCoefficient,
198
>
CheckpointInterval: f.Config.TimerProcessorUpdateAckInterval,
199
>
CheckpointIntervalJitterCoefficient: f.Config.TimerProcessorUpdateAckIntervalJitterCoefficient,
200
>
MaxReaderCount: f.Config.TimerQueueMaxReaderCount,
201
>
MoveGroupTaskCountBase: f.Config.QueueMoveGroupTaskCountBase,
202
>
MoveGroupTaskCountMultiplier: f.Config.QueueMoveGroupTaskCountMultiplier,
203
>
ShrinkPredicateMaxPendingKeys: f.Config.QueueShrinkPredicateMaxPendingKeys,
204
>
},
205
>
f.HostReaderRateLimiter,
206
>
logger,
207
>
metricsHandler,
208
>
)
209
}