Skip to content

Commit 222f725

Browse files
committed
Add buffer and replay logic
1 parent e83cb2b commit 222f725

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

internal/internal_event_handlers.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ import (
4343
)
4444

4545
const (
46-
queryResultSizeLimit = 2000000 // 2MB
46+
queryResultSizeLimit = 2000000 // 2MB
47+
historySizeEstimationBuffer = 1 * 128 // 128B
4748
)
4849

4950
// Make sure that interfaces are implemented
@@ -940,9 +941,11 @@ func (weh *workflowExecutionEventHandlerImpl) ProcessEvent(
940941
return err
941942
}
942943

943-
historySizeErr := weh.estimateHistorySize(event)
944-
if historySizeErr != nil {
945-
weh.logger.Error("Failed to estimate history size", zap.Error(historySizeErr))
944+
if !isReplay {
945+
historySizeErr := weh.estimateHistorySize(event)
946+
if historySizeErr != nil {
947+
weh.logger.Error("Failed to estimate history size", zap.Error(historySizeErr))
948+
}
946949
}
947950

948951
// When replaying histories to get stack trace or current state the last event might be not
@@ -1386,7 +1389,7 @@ func (weh *workflowExecutionEventHandlerImpl) handleSignalExternalWorkflowExecut
13861389
}
13871390

13881391
func (weh *workflowExecutionEventHandlerImpl) estimateHistorySize(event *m.HistoryEvent) error {
1389-
sum := 0
1392+
sum := historySizeEstimationBuffer
13901393
switch event.GetEventType() {
13911394
case m.EventTypeWorkflowExecutionStarted:
13921395
if event.WorkflowExecutionStartedEventAttributes != nil {

0 commit comments

Comments
 (0)