Skip to content

Commit fb247eb

Browse files
committed
update logic
1 parent 9e6216f commit fb247eb

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

internal/internal_task_handlers.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -371,12 +371,14 @@ OrderEvents:
371371
eh.currentIndex = 0
372372

373373
// estimate history size for nextEvents and markers
374-
historySizeEstimation = estimateHistorySize(nextEvents) + estimateHistorySize(markers)
374+
historySizeEstimation += estimateHistorySize(nextEvents)
375+
historySizeEstimation += estimateHistorySize(markers)
375376

376377
return nextEvents, markers, historySizeEstimation, nil
377378
}
378379

379-
func estimateHistorySize(events []*s.HistoryEvent) (sum int) {
380+
func estimateHistorySize(events []*s.HistoryEvent) int {
381+
sum := 0
380382
for _, e := range events {
381383
switch e.GetEventType() {
382384
case s.EventTypeWorkflowExecutionStarted:
@@ -474,10 +476,13 @@ func estimateHistorySize(events []*s.HistoryEvent) (sum int) {
474476
sum += len(e.SignalExternalWorkflowExecutionInitiatedEventAttributes.Control)
475477
sum += len(e.SignalExternalWorkflowExecutionInitiatedEventAttributes.Input)
476478
}
479+
default:
480+
// ignore other events
481+
477482
}
478483
}
479484
sum += historySizeEstimationOffset
480-
return
485+
return sum
481486
}
482487

483488
func isPreloadMarkerEvent(event *s.HistoryEvent) bool {
@@ -959,7 +964,6 @@ func (w *workflowExecutionContextImpl) ProcessWorkflowTask(workflowTask *workflo
959964
// Process events
960965
ProcessEvents:
961966
for {
962-
var historySizeEstimation int
963967
reorderedEvents, markers, binaryChecksum, historySizeEstimation, err := reorderedHistory.NextDecisionEvents()
964968
if err != nil {
965969
return nil, err

0 commit comments

Comments
 (0)