@@ -27,8 +27,6 @@ import (
27
27
"fmt"
28
28
"time"
29
29
30
- "go.uber.org/cadence/.gen/go/cadence/workflowserviceclient"
31
-
32
30
"github.com/uber/cadence/client/matching"
33
31
"github.com/uber/cadence/client/wrappers/retryable"
34
32
"github.com/uber/cadence/common"
@@ -43,10 +41,7 @@ import (
43
41
"github.com/uber/cadence/common/metrics"
44
42
cndc "github.com/uber/cadence/common/ndc"
45
43
"github.com/uber/cadence/common/persistence"
46
- "github.com/uber/cadence/common/quotas"
47
- "github.com/uber/cadence/common/quotas/permember"
48
44
"github.com/uber/cadence/common/reconciliation/invariant"
49
- "github.com/uber/cadence/common/service"
50
45
"github.com/uber/cadence/common/types"
51
46
"github.com/uber/cadence/common/types/mapper/proto"
52
47
hcommon "github.com/uber/cadence/service/history/common"
@@ -61,10 +56,8 @@ import (
61
56
"github.com/uber/cadence/service/history/replication"
62
57
"github.com/uber/cadence/service/history/reset"
63
58
"github.com/uber/cadence/service/history/shard"
64
- "github.com/uber/cadence/service/history/task"
65
59
"github.com/uber/cadence/service/history/workflow"
66
- "github.com/uber/cadence/service/history/workflowcache"
67
- warchiver "github.com/uber/cadence/service/worker/archiver"
60
+ "github.com/uber/cadence/service/worker/archiver"
68
61
)
69
62
70
63
const (
@@ -92,8 +85,7 @@ type historyEngineImpl struct {
92
85
historyV2Mgr persistence.HistoryManager
93
86
executionManager persistence.ExecutionManager
94
87
visibilityMgr persistence.VisibilityManager
95
- txProcessor queue.Processor
96
- timerProcessor queue.Processor
88
+ queueProcessors map [persistence.HistoryTaskCategory ]queue.Processor
97
89
nDCReplicator ndc.HistoryReplicator
98
90
nDCActivityReplicator ndc.ActivityReplicator
99
91
historyEventNotifier events.Notifier
@@ -104,22 +96,19 @@ type historyEngineImpl struct {
104
96
throttledLogger log.Logger
105
97
activeClusterManager activecluster.Manager
106
98
config * config.Config
107
- archivalClient warchiver .Client
99
+ archivalClient archiver .Client
108
100
workflowResetter reset.WorkflowResetter
109
- queueTaskProcessor task.Processor
110
101
replicationTaskProcessors []replication.TaskProcessor
111
102
replicationAckManager replication.TaskAckManager
112
103
replicationTaskStore * replication.TaskStore
113
104
replicationHydrator replication.TaskHydrator
114
105
replicationMetricsEmitter * replication.MetricsEmitterImpl
115
- publicClient workflowserviceclient.Interface
116
106
eventsReapplier ndc.EventsReapplier
117
107
matchingClient matching.Client
118
108
rawMatchingClient matching.Client
119
109
clientChecker client.VersionChecker
120
110
replicationDLQHandler replication.DLQHandler
121
111
failoverMarkerNotifier failover.MarkerNotifier
122
- wfIDCache workflowcache.WFCache
123
112
124
113
updateWithActionFn func (
125
114
context.Context ,
@@ -149,15 +138,12 @@ func NewEngineWithShardContext(
149
138
shard shard.Context ,
150
139
visibilityMgr persistence.VisibilityManager ,
151
140
matching matching.Client ,
152
- publicClient workflowserviceclient.Interface ,
153
141
historyEventNotifier events.Notifier ,
154
142
config * config.Config ,
155
143
replicationTaskFetchers replication.TaskFetchers ,
156
144
rawMatchingClient matching.Client ,
157
- queueTaskProcessor task.Processor ,
158
145
failoverCoordinator failover.Coordinator ,
159
- wfIDCache workflowcache.WFCache ,
160
- queueProcessorFactory queue.ProcessorFactory ,
146
+ queueFactories []queue.Factory ,
161
147
) engine.Engine {
162
148
currentClusterName := shard .GetService ().GetClusterMetadata ().GetCurrentClusterName ()
163
149
@@ -194,40 +180,13 @@ func NewEngineWithShardContext(
194
180
metricsClient : shard .GetMetricsClient (),
195
181
historyEventNotifier : historyEventNotifier ,
196
182
config : config ,
197
- archivalClient : warchiver .NewClient (
198
- shard .GetMetricsClient (),
199
- logger ,
200
- publicClient ,
201
- shard .GetConfig ().NumArchiveSystemWorkflows ,
202
- quotas .NewDynamicRateLimiter (config .ArchiveRequestRPS .AsFloat64 ()),
203
- quotas .NewDynamicRateLimiter (func () float64 {
204
- return permember .PerMember (
205
- service .History ,
206
- float64 (config .ArchiveInlineHistoryGlobalRPS ()),
207
- float64 (config .ArchiveInlineHistoryRPS ()),
208
- shard .GetService ().GetMembershipResolver (),
209
- )
210
- }),
211
- quotas .NewDynamicRateLimiter (func () float64 {
212
- return permember .PerMember (
213
- service .History ,
214
- float64 (config .ArchiveInlineVisibilityGlobalRPS ()),
215
- float64 (config .ArchiveInlineVisibilityRPS ()),
216
- shard .GetService ().GetMembershipResolver (),
217
- )
218
- }),
219
- shard .GetService ().GetArchiverProvider (),
220
- config .AllowArchivingIncompleteHistory ,
221
- ),
222
183
workflowResetter : reset .NewWorkflowResetter (
223
184
shard ,
224
185
executionCache ,
225
186
logger ,
226
187
),
227
- publicClient : publicClient ,
228
188
matchingClient : matching ,
229
189
rawMatchingClient : rawMatchingClient ,
230
- queueTaskProcessor : queueTaskProcessor ,
231
190
clientChecker : client .NewVersionChecker (),
232
191
failoverMarkerNotifier : failoverMarkerNotifier ,
233
192
replicationHydrator : replicationHydrator ,
@@ -246,8 +205,8 @@ func NewEngineWithShardContext(
246
205
replicationTaskStore : replicationTaskStore ,
247
206
replicationMetricsEmitter : replication .NewMetricsEmitter (
248
207
shard .GetShardID (), shard , replicationReader , shard .GetMetricsClient ()),
249
- wfIDCache : wfIDCache ,
250
208
updateWithActionFn : workflow .UpdateWithAction ,
209
+ queueProcessors : make (map [persistence.HistoryTaskCategory ]queue.Processor ),
251
210
}
252
211
historyEngImpl .decisionHandler = decision .NewHandler (
253
212
shard ,
@@ -261,25 +220,13 @@ func NewEngineWithShardContext(
261
220
)
262
221
openExecutionCheck := invariant .NewConcreteExecutionExists (pRetry , shard .GetDomainCache ())
263
222
264
- historyEngImpl .txProcessor = queueProcessorFactory .NewTransferQueueProcessor (
265
- shard ,
266
- historyEngImpl ,
267
- queueTaskProcessor ,
268
- executionCache ,
269
- historyEngImpl .workflowResetter ,
270
- historyEngImpl .archivalClient ,
271
- openExecutionCheck ,
272
- historyEngImpl .wfIDCache ,
273
- )
274
-
275
- historyEngImpl .timerProcessor = queueProcessorFactory .NewTimerQueueProcessor (
276
- shard ,
277
- historyEngImpl ,
278
- queueTaskProcessor ,
279
- executionCache ,
280
- historyEngImpl .archivalClient ,
281
- openExecutionCheck ,
282
- )
223
+ for _ , factory := range queueFactories {
224
+ historyEngImpl .queueProcessors [factory .Category ()] = factory .CreateQueue (
225
+ shard ,
226
+ executionCache ,
227
+ openExecutionCheck ,
228
+ )
229
+ }
283
230
284
231
historyEngImpl .eventsReapplier = ndc .NewEventsReapplier (shard .GetMetricsClient (), logger )
285
232
@@ -360,8 +307,9 @@ func (e *historyEngineImpl) Start() {
360
307
e .logger .Info ("History engine state changed" , tag .LifeCycleStarting )
361
308
defer e .logger .Info ("History engine state changed" , tag .LifeCycleStarted )
362
309
363
- e .txProcessor .Start ()
364
- e .timerProcessor .Start ()
310
+ for _ , processor := range e .queueProcessors {
311
+ processor .Start ()
312
+ }
365
313
e .replicationDLQHandler .Start ()
366
314
e .replicationMetricsEmitter .Start ()
367
315
@@ -386,8 +334,9 @@ func (e *historyEngineImpl) Stop() {
386
334
e .logger .Info ("History engine state changed" , tag .LifeCycleStopping )
387
335
defer e .logger .Info ("History engine state changed" , tag .LifeCycleStopped )
388
336
389
- e .txProcessor .Stop ()
390
- e .timerProcessor .Stop ()
337
+ for _ , processor := range e .queueProcessors {
338
+ processor .Stop ()
339
+ }
391
340
e .replicationDLQHandler .Stop ()
392
341
e .replicationMetricsEmitter .Stop ()
393
342
@@ -420,8 +369,9 @@ func (e *historyEngineImpl) SyncShardStatus(ctx context.Context, request *types.
420
369
// 2. notify the timer gate in the timer queue standby processor
421
370
// 3. notify the transfer (essentially a no op, just put it here so it looks symmetric)
422
371
e .shard .SetCurrentTime (clusterName , now )
423
- e .txProcessor .NotifyNewTask (clusterName , & hcommon.NotifyTaskInfo {Tasks : []persistence.Task {}})
424
- e .timerProcessor .NotifyNewTask (clusterName , & hcommon.NotifyTaskInfo {Tasks : []persistence.Task {}})
372
+ for _ , processor := range e .queueProcessors {
373
+ processor .NotifyNewTask (clusterName , & hcommon.NotifyTaskInfo {Tasks : []persistence.Task {}})
374
+ }
425
375
return nil
426
376
}
427
377
0 commit comments