58
58
RemoteCluster string // TODO: Remove this remote cluster from executor then it can use singleton.
59
59
Shard shard.Context
60
60
HistoryResender xdc.NDCHistoryResender
61
- HistoryEngine shard.Engine
62
61
DeleteManager deletemanager.DeleteManager
63
62
WorkflowCache wcache.Cache
64
63
}
@@ -68,10 +67,9 @@ type (
68
67
taskExecutorImpl struct {
69
68
currentCluster string
70
69
remoteCluster string
71
- shard shard.Context
70
+ shardContext shard.Context
72
71
namespaceRegistry namespace.Registry
73
72
nDCHistoryResender xdc.NDCHistoryResender
74
- historyEngine shard.Engine
75
73
deleteManager deletemanager.DeleteManager
76
74
workflowCache wcache.Cache
77
75
metricsHandler metrics.Handler
@@ -83,23 +81,21 @@ type (
83
81
// The executor uses by 1) DLQ replication task handler 2) history replication task processor
84
82
func NewTaskExecutor (
85
83
remoteCluster string ,
86
- shard shard.Context ,
84
+ shardContext shard.Context ,
87
85
nDCHistoryResender xdc.NDCHistoryResender ,
88
- historyEngine shard.Engine ,
89
86
deleteManager deletemanager.DeleteManager ,
90
87
workflowCache wcache.Cache ,
91
88
) TaskExecutor {
92
89
return & taskExecutorImpl {
93
- currentCluster : shard .GetClusterMetadata ().GetCurrentClusterName (),
90
+ currentCluster : shardContext .GetClusterMetadata ().GetCurrentClusterName (),
94
91
remoteCluster : remoteCluster ,
95
- shard : shard ,
96
- namespaceRegistry : shard .GetNamespaceRegistry (),
92
+ shardContext : shardContext ,
93
+ namespaceRegistry : shardContext .GetNamespaceRegistry (),
97
94
nDCHistoryResender : nDCHistoryResender ,
98
- historyEngine : historyEngine ,
99
95
deleteManager : deleteManager ,
100
96
workflowCache : workflowCache ,
101
- metricsHandler : shard .GetMetricsHandler (),
102
- logger : shard .GetLogger (),
97
+ metricsHandler : shardContext .GetMetricsHandler (),
98
+ logger : shardContext .GetLogger (),
103
99
}
104
100
}
105
101
@@ -167,7 +163,9 @@ func (e *taskExecutorImpl) handleActivityTask(
167
163
ctx , cancel := e .newTaskContext (ctx , attr .NamespaceId )
168
164
defer cancel ()
169
165
170
- err = e .historyEngine .SyncActivity (ctx , request )
166
+ // This might be extra cost if the workflow belongs to local shard.
167
+ // Add a wrapper of the history client to call history engine directly if it becomes an issue.
168
+ _ , err = e .shardContext .GetHistoryClient ().SyncActivity (ctx , request )
171
169
switch retryErr := err .(type ) {
172
170
case nil :
173
171
return nil
@@ -206,7 +204,10 @@ func (e *taskExecutorImpl) handleActivityTask(
206
204
e .logger .Error ("error resend history for history event" , tag .Error (resendErr ))
207
205
return err
208
206
}
209
- return e .historyEngine .SyncActivity (ctx , request )
207
+ // This might be extra cost if the workflow belongs to local shard.
208
+ // Add a wrapper of the history client to call history engine directly if it becomes an issue.
209
+ _ , err = e .shardContext .GetHistoryClient ().SyncActivity (ctx , request )
210
+ return err
210
211
211
212
default :
212
213
return err
@@ -247,7 +248,9 @@ func (e *taskExecutorImpl) handleHistoryReplicationTask(
247
248
ctx , cancel := e .newTaskContext (ctx , attr .NamespaceId )
248
249
defer cancel ()
249
250
250
- err = e .historyEngine .ReplicateEventsV2 (ctx , request )
251
+ // This might be extra cost if the workflow belongs to local shard.
252
+ // Add a wrapper of the history client to call history engine directly if it becomes an issue.
253
+ _ , err = e .shardContext .GetHistoryClient ().ReplicateEventsV2 (ctx , request )
251
254
switch retryErr := err .(type ) {
252
255
case nil :
253
256
return nil
@@ -287,7 +290,10 @@ func (e *taskExecutorImpl) handleHistoryReplicationTask(
287
290
return err
288
291
}
289
292
290
- return e .historyEngine .ReplicateEventsV2 (ctx , request )
293
+ // This might be extra cost if the workflow belongs to local shard.
294
+ // Add a wrapper of the history client to call history engine directly if it becomes an issue.
295
+ _ , err = e .shardContext .GetHistoryClient ().ReplicateEventsV2 (ctx , request )
296
+ return err
291
297
292
298
default :
293
299
return err
@@ -312,10 +318,13 @@ func (e *taskExecutorImpl) handleSyncWorkflowStateTask(
312
318
ctx , cancel := e .newTaskContext (ctx , executionInfo .NamespaceId )
313
319
defer cancel ()
314
320
315
- return e .historyEngine .ReplicateWorkflowState (ctx , & historyservice.ReplicateWorkflowStateRequest {
321
+ // This might be extra cost if the workflow belongs to local shard.
322
+ // Add a wrapper of the history client to call history engine directly if it becomes an issue.
323
+ _ , err = e .shardContext .GetHistoryClient ().ReplicateWorkflowState (ctx , & historyservice.ReplicateWorkflowStateRequest {
316
324
WorkflowState : attr .GetWorkflowState (),
317
325
RemoteCluster : e .remoteCluster ,
318
326
})
327
+ return err
319
328
}
320
329
321
330
func (e * taskExecutorImpl ) filterTask (
0 commit comments