209
task *replicationspb.ReplicationTask,
210
forceApply bool,
212
>
213
>
attr := task.GetHistoryTaskAttributes()
214
>
doContinue, err := e.filterTask(namespace.ID(attr.GetNamespaceId()), attr.WorkflowId, forceApply)
215
>
if err != nil || !doContinue {
216
return err
217
}
218
220
>
defer func() {
221
>
metrics.ServiceLatency.With(e.metricsHandler).Record(
222
>
time.Since(startTime),
223
>
metrics.OperationTag(metrics.HistoryReplicationTaskScope),
224
>
metrics.NamespaceTag(attr.GetNamespaceId()),
225
>
)
226
>
}()
227
229
>
NamespaceId: attr.NamespaceId,
230
>
WorkflowExecution: &commonpb.WorkflowExecution{
231
>
WorkflowId: attr.WorkflowId,
232
>
RunId: attr.RunId,
233
>
},
234
>
VersionHistoryItems: attr.VersionHistoryItems,
235
>
Events: attr.Events,
236
>
// new run events does not need version history since there is no prior events
237
>
NewRunEvents: attr.NewRunEvents,
238
>
NewRunId: attr.NewRunId,
239
>
}
240
>
namespaceName, _ := e.namespaceRegistry.GetNamespaceName(namespace.ID(attr.NamespaceId))
241
>
ctx, cancel := e.newTaskContext(ctx, namespaceName)
242
>
defer cancel()
243
>
244
>
// This might be extra cost if the workflow belongs to local shard.
245
>
// Add a wrapper of the history client to call history engine directly if it becomes an issue.
246
>
_, err = e.shardContext.GetHistoryClient().ReplicateEventsV2(ctx, request)
247
>
switch retryErr := err.(type) {
248
case nil:
249
return nil