diff --git a/common/types/shared.go b/common/types/shared.go index 5b49fc02721..972f4820972 100644 --- a/common/types/shared.go +++ b/common/types/shared.go @@ -63,6 +63,21 @@ func (v *ActivityTaskCancelRequestedEventAttributes) GetActivityID() (o string) return } +// Size returns the approximate memory used in bytes +func (v *ActivityTaskCancelRequestedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) + + if v.ActivityID != "" { + size += uint64(16 + len(v.ActivityID)) + } + + return size +} + // ActivityTaskCanceledEventAttributes is an internal type (TBD...) type ActivityTaskCanceledEventAttributes struct { Details []byte `json:"details,omitempty"` @@ -80,6 +95,25 @@ func (v *ActivityTaskCanceledEventAttributes) GetScheduledEventID() (o int64) { return } +// Size returns the approximate memory used in bytes +func (v *ActivityTaskCanceledEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) + + if v.Details != nil { + size += uint64(len(v.Details)) + } + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + return size +} + // ActivityTaskCompletedEventAttributes is an internal type (TBD...) type ActivityTaskCompletedEventAttributes struct { Result []byte `json:"result,omitempty"` @@ -104,6 +138,25 @@ func (v *ActivityTaskCompletedEventAttributes) GetStartedEventID() (o int64) { return } +// Size returns the approximate memory used in bytes +func (v *ActivityTaskCompletedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) + + if v.Result != nil { + size += uint64(len(v.Result)) + } + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + return size +} + // ActivityTaskFailedEventAttributes is an internal type (TBD...) type ActivityTaskFailedEventAttributes struct { Reason *string `json:"reason,omitempty"` @@ -129,6 +182,29 @@ func (v *ActivityTaskFailedEventAttributes) GetStartedEventID() (o int64) { return } +// Size returns the approximate memory used in bytes +func (v *ActivityTaskFailedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) + + if v.Reason != nil { + size += uint64(16 + len(*v.Reason)) + } + + if v.Details != nil { + size += uint64(len(v.Details)) + } + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + return size +} + // ActivityTaskScheduledEventAttributes is an internal type (TBD...) type ActivityTaskScheduledEventAttributes struct { ActivityID string `json:"activityId,omitempty"` @@ -209,6 +285,64 @@ func (v *ActivityTaskScheduledEventAttributes) GetHeartbeatTimeoutSeconds() (o i return } +// Size returns the approximate memory used in bytes +func (v *ActivityTaskScheduledEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(40) + + if v.ActivityID != "" { + size += uint64(16 + len(v.ActivityID)) + } + + if v.ActivityType != nil { + if v.ActivityType.Name != "" { + size += uint64(16 + len(v.ActivityType.Name)) + } + size += 8 + } + + if v.Domain != nil { + size += uint64(16 + len(*v.Domain)) + size += 8 + } + + if v.TaskList != nil { + if v.TaskList.Name != "" { + size += uint64(16 + len(v.TaskList.Name)) + } + size += 16 + } + + if v.Input != nil { + size += uint64(len(v.Input)) + } + + if v.ScheduleToCloseTimeoutSeconds != nil { + size += 8 + } + if v.ScheduleToStartTimeoutSeconds != nil { + size += 8 + } + if v.StartToCloseTimeoutSeconds != nil { + size += 8 + } + if v.HeartbeatTimeoutSeconds != nil { + size += 8 + } + + if v.RetryPolicy != nil { + size += 24 + } + if v.Header != nil { + size += 16 + } + + return size +} + // ActivityTaskStartedEventAttributes is an internal type (TBD...) type ActivityTaskStartedEventAttributes struct { ScheduledEventID int64 `json:"scheduledEventId,omitempty"` @@ -235,6 +369,34 @@ func (v *ActivityTaskStartedEventAttributes) GetRequestID() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *ActivityTaskStartedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + if v.RequestID != "" { + size += uint64(16 + len(v.RequestID)) + } + + if v.LastFailureReason != nil { + size += uint64(16 + len(*v.LastFailureReason)) + size += 8 + } + + if v.LastFailureDetails != nil { + size += uint64(len(v.LastFailureDetails)) + } + + return size +} + // ActivityTaskTimedOutEventAttributes is an internal type (TBD...) type ActivityTaskTimedOutEventAttributes struct { Details []byte `json:"details,omitempty"` @@ -261,6 +423,33 @@ func (v *ActivityTaskTimedOutEventAttributes) GetTimeoutType() (o TimeoutType) { return } +// Size returns the approximate memory used in bytes +func (v *ActivityTaskTimedOutEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) + + if v.Details != nil { + size += uint64(len(v.Details)) + } + + if v.TimeoutType != nil { + size += 8 + } + + if v.LastFailureReason != nil { + size += uint64(16 + len(*v.LastFailureReason)) + } + + if v.LastFailureDetails != nil { + size += uint64(len(v.LastFailureDetails)) + } + + return size +} + // ActivityType is an internal type (TBD...) type ActivityType struct { Name string `json:"name,omitempty"` @@ -437,6 +626,29 @@ type CancelTimerFailedEventAttributes struct { Identity string `json:"identity,omitempty"` } +// Size returns the approximate memory used in bytes +func (v *CancelTimerFailedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) + + if v.TimerID != "" { + size += uint64(16 + len(v.TimerID)) + } + + if v.Cause != "" { + size += uint64(16 + len(v.Cause)) + } + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + return size +} + // CancelWorkflowExecutionDecisionAttributes is an internal type (TBD...) type CancelWorkflowExecutionDecisionAttributes struct { Details []byte `json:"details,omitempty"` @@ -465,6 +677,42 @@ func (v *ChildWorkflowExecutionCanceledEventAttributes) GetInitiatedEventID() (o return } +// Size returns the approximate memory used in bytes +func (v *ChildWorkflowExecutionCanceledEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(40) + + if v.Details != nil { + size += uint64(len(v.Details)) + } + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowExecution != nil { + size += 24 + if v.WorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowExecution.WorkflowID)) + } + if v.WorkflowExecution.RunID != "" { + size += uint64(16 + len(v.WorkflowExecution.RunID)) + } + } + + if v.WorkflowType != nil { + size += 16 + if v.WorkflowType.Name != "" { + size += uint64(16 + len(v.WorkflowType.Name)) + } + } + + return size +} + // ChildWorkflowExecutionCompletedEventAttributes is an internal type (TBD...) type ChildWorkflowExecutionCompletedEventAttributes struct { Result []byte `json:"result,omitempty"` @@ -483,6 +731,42 @@ func (v *ChildWorkflowExecutionCompletedEventAttributes) GetInitiatedEventID() ( return } +// Size returns the approximate memory used in bytes +func (v *ChildWorkflowExecutionCompletedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(40) + + if v.Result != nil { + size += uint64(len(v.Result)) + } + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowExecution != nil { + size += 24 + if v.WorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowExecution.WorkflowID)) + } + if v.WorkflowExecution.RunID != "" { + size += uint64(16 + len(v.WorkflowExecution.RunID)) + } + } + + if v.WorkflowType != nil { + size += 16 + if v.WorkflowType.Name != "" { + size += uint64(16 + len(v.WorkflowType.Name)) + } + } + + return size +} + // ChildWorkflowExecutionFailedCause is an internal type (TBD...) type ChildWorkflowExecutionFailedCause int32 @@ -546,6 +830,46 @@ func (v *ChildWorkflowExecutionFailedEventAttributes) GetInitiatedEventID() (o i return } +// Size returns the approximate memory used in bytes +func (v *ChildWorkflowExecutionFailedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(40) + + if v.Reason != nil { + size += uint64(16 + len(*v.Reason)) + } + + if v.Details != nil { + size += uint64(len(v.Details)) + } + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowExecution != nil { + size += 24 + if v.WorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowExecution.WorkflowID)) + } + if v.WorkflowExecution.RunID != "" { + size += uint64(16 + len(v.WorkflowExecution.RunID)) + } + } + + if v.WorkflowType != nil { + size += 16 + if v.WorkflowType.Name != "" { + size += uint64(16 + len(v.WorkflowType.Name)) + } + } + + return size +} + // ChildWorkflowExecutionStartedEventAttributes is an internal type (TBD...) type ChildWorkflowExecutionStartedEventAttributes struct { Domain string `json:"domain,omitempty"` @@ -579,6 +903,42 @@ func (v *ChildWorkflowExecutionStartedEventAttributes) GetWorkflowExecution() (o return } +// Size returns the approximate memory used in bytes +func (v *ChildWorkflowExecutionStartedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(32) + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowExecution != nil { + size += 24 + if v.WorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowExecution.WorkflowID)) + } + if v.WorkflowExecution.RunID != "" { + size += uint64(16 + len(v.WorkflowExecution.RunID)) + } + } + + if v.WorkflowType != nil { + size += 16 + if v.WorkflowType.Name != "" { + size += uint64(16 + len(v.WorkflowType.Name)) + } + } + + if v.Header != nil { + size += 16 + } + + return size +} + // ChildWorkflowExecutionTerminatedEventAttributes is an internal type (TBD...) type ChildWorkflowExecutionTerminatedEventAttributes struct { Domain string `json:"domain,omitempty"` @@ -596,6 +956,38 @@ func (v *ChildWorkflowExecutionTerminatedEventAttributes) GetInitiatedEventID() return } +// Size returns the approximate memory used in bytes +func (v *ChildWorkflowExecutionTerminatedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(40) + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowExecution != nil { + size += 24 + if v.WorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowExecution.WorkflowID)) + } + if v.WorkflowExecution.RunID != "" { + size += uint64(16 + len(v.WorkflowExecution.RunID)) + } + } + + if v.WorkflowType != nil { + size += 16 + if v.WorkflowType.Name != "" { + size += uint64(16 + len(v.WorkflowType.Name)) + } + } + + return size +} + // ChildWorkflowExecutionTimedOutEventAttributes is an internal type (TBD...) type ChildWorkflowExecutionTimedOutEventAttributes struct { TimeoutType *TimeoutType `json:"timeoutType,omitempty"` @@ -614,6 +1006,42 @@ func (v *ChildWorkflowExecutionTimedOutEventAttributes) GetInitiatedEventID() (o return } +// Size returns the approximate memory used in bytes +func (v *ChildWorkflowExecutionTimedOutEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(40) + + if v.TimeoutType != nil { + size += 8 + } + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowExecution != nil { + size += 24 + if v.WorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowExecution.WorkflowID)) + } + if v.WorkflowExecution.RunID != "" { + size += uint64(16 + len(v.WorkflowExecution.RunID)) + } + } + + if v.WorkflowType != nil { + size += 16 + if v.WorkflowType.Name != "" { + size += uint64(16 + len(v.WorkflowType.Name)) + } + } + + return size +} + // ClientVersionNotSupportedError is an internal type (TBD...) type ClientVersionNotSupportedError struct { FeatureVersion string `json:"featureVersion,required"` @@ -927,6 +1355,29 @@ func (v *DecisionTaskCompletedEventAttributes) GetBinaryChecksum() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *DecisionTaskCompletedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) + + if v.ExecutionContext != nil { + size += uint64(len(v.ExecutionContext)) + } + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + if v.BinaryChecksum != "" { + size += uint64(16 + len(v.BinaryChecksum)) + } + + return size +} + // DecisionTaskFailedCause is an internal type (TBD...) type DecisionTaskFailedCause int32 @@ -1188,6 +1639,49 @@ func (v *DecisionTaskFailedEventAttributes) GetRequestID() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *DecisionTaskFailedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(40) + + if v.Details != nil { + size += uint64(len(v.Details)) + } + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + if v.Reason != nil { + size += uint64(16 + len(*v.Reason)) + } + + if v.BaseRunID != "" { + size += uint64(16 + len(v.BaseRunID)) + } + + if v.NewRunID != "" { + size += uint64(16 + len(v.NewRunID)) + } + + if v.BinaryChecksum != "" { + size += uint64(16 + len(v.BinaryChecksum)) + } + + if v.RequestID != "" { + size += uint64(16 + len(v.RequestID)) + } + + if v.Cause != nil { + size += 8 + } + + return size +} + // DecisionTaskScheduledEventAttributes is an internal type (TBD...) type DecisionTaskScheduledEventAttributes struct { TaskList *TaskList `json:"taskList,omitempty"` @@ -1219,6 +1713,28 @@ func (v *DecisionTaskScheduledEventAttributes) GetAttempt() (o int64) { return } +// Size returns the approximate memory used in bytes +func (v *DecisionTaskScheduledEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(16) + + if v.TaskList != nil { + size += 16 + if v.TaskList.Name != "" { + size += uint64(16 + len(v.TaskList.Name)) + } + } + + if v.StartToCloseTimeoutSeconds != nil { + size += 8 + } + + return size +} + // DecisionTaskStartedEventAttributes is an internal type (TBD...) type DecisionTaskStartedEventAttributes struct { ScheduledEventID int64 `json:"scheduledEventId,omitempty"` @@ -1242,6 +1758,25 @@ func (v *DecisionTaskStartedEventAttributes) GetRequestID() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *DecisionTaskStartedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(16) + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + if v.RequestID != "" { + size += uint64(16 + len(v.RequestID)) + } + + return size +} + // DecisionTaskTimedOutCause is an internal type (TBD...) type DecisionTaskTimedOutCause int32 @@ -1362,6 +1897,41 @@ func (v *DecisionTaskTimedOutEventAttributes) GetRequestID() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *DecisionTaskTimedOutEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(32) + + if v.TimeoutType != nil { + size += 8 + } + + if v.BaseRunID != "" { + size += uint64(16 + len(v.BaseRunID)) + } + + if v.NewRunID != "" { + size += uint64(16 + len(v.NewRunID)) + } + + if v.Reason != "" { + size += uint64(16 + len(v.Reason)) + } + + if v.Cause != nil { + size += 8 + } + + if v.RequestID != "" { + size += uint64(16 + len(v.RequestID)) + } + + return size +} + // DecisionType is an internal type (TBD...) type DecisionType int32 @@ -2434,6 +3004,31 @@ func (v *ExternalWorkflowExecutionCancelRequestedEventAttributes) GetDomain() (o return } +// Size returns the approximate memory used in bytes +func (v *ExternalWorkflowExecutionCancelRequestedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) // Base struct size + initiatedEventId + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowExecution != nil { + size += 24 // Struct overhead + if v.WorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowExecution.WorkflowID)) + } + if v.WorkflowExecution.RunID != "" { + size += uint64(16 + len(v.WorkflowExecution.RunID)) + } + } + + return size +} + // ExternalWorkflowExecutionSignaledEventAttributes is an internal type (TBD...) type ExternalWorkflowExecutionSignaledEventAttributes struct { InitiatedEventID int64 `json:"initiatedEventId,omitempty"` @@ -2458,6 +3053,35 @@ func (v *ExternalWorkflowExecutionSignaledEventAttributes) GetDomain() (o string return } +// Size returns the approximate memory used in bytes +func (v *ExternalWorkflowExecutionSignaledEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) // Base struct size + initiatedEventId + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowExecution != nil { + size += 24 // Struct overhead + if v.WorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowExecution.WorkflowID)) + } + if v.WorkflowExecution.RunID != "" { + size += uint64(16 + len(v.WorkflowExecution.RunID)) + } + } + + if v.Control != nil { + size += uint64(len(v.Control)) + } + + return size +} + // FailWorkflowExecutionDecisionAttributes is an internal type (TBD...) type FailWorkflowExecutionDecisionAttributes struct { Reason *string `json:"reason,omitempty"` @@ -3060,6 +3684,185 @@ func (v *HistoryEvent) GetUpsertWorkflowSearchAttributesEventAttributes() (o *Up return } +// Size is an internal method to get the estimated size of the event +func (v *HistoryEvent) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(8 + 8 + 4 + 8 + 8) // size of ID, Timestamp, EventType, Version, TaskID + + if v.WorkflowExecutionStartedEventAttributes != nil { + size += v.WorkflowExecutionStartedEventAttributes.Size() + } + + if v.WorkflowExecutionCompletedEventAttributes != nil { + size += v.WorkflowExecutionCompletedEventAttributes.Size() + } + + if v.WorkflowExecutionFailedEventAttributes != nil { + size += v.WorkflowExecutionFailedEventAttributes.Size() + } + + if v.WorkflowExecutionTimedOutEventAttributes != nil { + size += v.WorkflowExecutionTimedOutEventAttributes.Size() + } + + if v.WorkflowExecutionCancelRequestedEventAttributes != nil { + size += v.WorkflowExecutionCancelRequestedEventAttributes.Size() + } + + if v.WorkflowExecutionCanceledEventAttributes != nil { + size += v.WorkflowExecutionCanceledEventAttributes.Size() + } + + if v.WorkflowExecutionTerminatedEventAttributes != nil { + size += v.WorkflowExecutionTerminatedEventAttributes.Size() + } + + if v.WorkflowExecutionContinuedAsNewEventAttributes != nil { + size += v.WorkflowExecutionContinuedAsNewEventAttributes.Size() + } + + if v.WorkflowExecutionSignaledEventAttributes != nil { + size += v.WorkflowExecutionSignaledEventAttributes.Size() + } + + if v.DecisionTaskScheduledEventAttributes != nil { + size += v.DecisionTaskScheduledEventAttributes.Size() + } + + if v.DecisionTaskStartedEventAttributes != nil { + size += v.DecisionTaskStartedEventAttributes.Size() + } + + if v.DecisionTaskCompletedEventAttributes != nil { + size += v.DecisionTaskCompletedEventAttributes.Size() + } + + if v.DecisionTaskTimedOutEventAttributes != nil { + size += v.DecisionTaskTimedOutEventAttributes.Size() + } + + if v.DecisionTaskFailedEventAttributes != nil { + size += v.DecisionTaskFailedEventAttributes.Size() + } + + if v.ActivityTaskScheduledEventAttributes != nil { + size += v.ActivityTaskScheduledEventAttributes.Size() + } + + if v.ActivityTaskStartedEventAttributes != nil { + size += v.ActivityTaskStartedEventAttributes.Size() + } + + if v.ActivityTaskCompletedEventAttributes != nil { + size += v.ActivityTaskCompletedEventAttributes.Size() + } + + if v.ActivityTaskFailedEventAttributes != nil { + size += v.ActivityTaskFailedEventAttributes.Size() + } + + if v.ActivityTaskTimedOutEventAttributes != nil { + size += v.ActivityTaskTimedOutEventAttributes.Size() + } + + if v.ActivityTaskCancelRequestedEventAttributes != nil { + size += v.ActivityTaskCancelRequestedEventAttributes.Size() + } + + if v.ActivityTaskCanceledEventAttributes != nil { + size += v.ActivityTaskCanceledEventAttributes.Size() + } + + if v.RequestCancelActivityTaskFailedEventAttributes != nil { + size += v.RequestCancelActivityTaskFailedEventAttributes.Size() + } + + if v.TimerStartedEventAttributes != nil { + size += v.TimerStartedEventAttributes.Size() + } + + if v.TimerFiredEventAttributes != nil { + size += v.TimerFiredEventAttributes.Size() + } + + if v.TimerCanceledEventAttributes != nil { + size += v.TimerCanceledEventAttributes.Size() + } + + if v.CancelTimerFailedEventAttributes != nil { + size += v.CancelTimerFailedEventAttributes.Size() + } + + if v.MarkerRecordedEventAttributes != nil { + size += v.MarkerRecordedEventAttributes.Size() + } + + if v.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes != nil { + size += v.RequestCancelExternalWorkflowExecutionInitiatedEventAttributes.Size() + } + + if v.RequestCancelExternalWorkflowExecutionFailedEventAttributes != nil { + size += v.RequestCancelExternalWorkflowExecutionFailedEventAttributes.Size() + } + + if v.ExternalWorkflowExecutionCancelRequestedEventAttributes != nil { + size += v.ExternalWorkflowExecutionCancelRequestedEventAttributes.Size() + } + + if v.SignalExternalWorkflowExecutionInitiatedEventAttributes != nil { + size += v.SignalExternalWorkflowExecutionInitiatedEventAttributes.Size() + } + + if v.SignalExternalWorkflowExecutionFailedEventAttributes != nil { + size += v.SignalExternalWorkflowExecutionFailedEventAttributes.Size() + } + + if v.ExternalWorkflowExecutionSignaledEventAttributes != nil { + size += v.ExternalWorkflowExecutionSignaledEventAttributes.Size() + } + + if v.StartChildWorkflowExecutionInitiatedEventAttributes != nil { + size += v.StartChildWorkflowExecutionInitiatedEventAttributes.Size() + } + + if v.StartChildWorkflowExecutionFailedEventAttributes != nil { + size += v.StartChildWorkflowExecutionFailedEventAttributes.Size() + } + + if v.ChildWorkflowExecutionStartedEventAttributes != nil { + size += v.ChildWorkflowExecutionStartedEventAttributes.Size() + } + + if v.ChildWorkflowExecutionCompletedEventAttributes != nil { + size += v.ChildWorkflowExecutionCompletedEventAttributes.Size() + } + + if v.ChildWorkflowExecutionFailedEventAttributes != nil { + size += v.ChildWorkflowExecutionFailedEventAttributes.Size() + } + + if v.ChildWorkflowExecutionCanceledEventAttributes != nil { + size += v.ChildWorkflowExecutionCanceledEventAttributes.Size() + } + + if v.ChildWorkflowExecutionTimedOutEventAttributes != nil { + size += v.ChildWorkflowExecutionTimedOutEventAttributes.Size() + } + + if v.ChildWorkflowExecutionTerminatedEventAttributes != nil { + size += v.ChildWorkflowExecutionTerminatedEventAttributes.Size() + } + + if v.UpsertWorkflowSearchAttributesEventAttributes != nil { + size += v.UpsertWorkflowSearchAttributesEventAttributes.Size() + } + + return size +} + // HistoryEventFilterType is an internal type (TBD...) type HistoryEventFilterType int32 @@ -3517,6 +4320,35 @@ func (v *MarkerRecordedEventAttributes) GetMarkerName() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *MarkerRecordedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) // Base struct size + decisionTaskCompletedEventId + + if v.MarkerName != "" { + size += uint64(16 + len(v.MarkerName)) + } + + if v.Details != nil { + size += uint64(len(v.Details)) + } + + if v.Header != nil { + size += 16 + if v.Header.Fields != nil { + size += 16 + for k, v := range v.Header.Fields { + size += uint64(16 + len(k) + len(v)) + } + } + } + + return size +} + // Memo is an internal type (TBD...) type Memo struct { Fields map[string][]byte `json:"fields,omitempty"` @@ -4570,11 +5402,21 @@ func (v *RegisterDomainRequest) GetVisibilityArchivalURI() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *RegisterDomainRequest) Size() uint64 { + return 0 +} + // RemoteSyncMatchedError is an internal type (TBD...) type RemoteSyncMatchedError struct { Message string `json:"message,required"` } +// Size returns the approximate memory used in bytes +func (v *RemoteSyncMatchedError) Size() uint64 { + return 0 +} + // RemoveTaskRequest is an internal type (TBD...) type RemoveTaskRequest struct { ShardID int32 `json:"shardID,omitempty"` @@ -4624,6 +5466,11 @@ func (v *RemoveTaskRequest) GetClusterName() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *RemoveTaskRequest) Size() uint64 { + return 0 +} + // RequestCancelActivityTaskDecisionAttributes is an internal type (TBD...) type RequestCancelActivityTaskDecisionAttributes struct { ActivityID string `json:"activityId,omitempty"` @@ -4637,6 +5484,11 @@ func (v *RequestCancelActivityTaskDecisionAttributes) GetActivityID() (o string) return } +// Size returns the approximate memory used in bytes +func (v *RequestCancelActivityTaskDecisionAttributes) Size() uint64 { + return 0 +} + // RequestCancelActivityTaskFailedEventAttributes is an internal type (TBD...) type RequestCancelActivityTaskFailedEventAttributes struct { ActivityID string `json:"activityId,omitempty"` @@ -4644,6 +5496,25 @@ type RequestCancelActivityTaskFailedEventAttributes struct { DecisionTaskCompletedEventID int64 `json:"decisionTaskCompletedEventId,omitempty"` } +// Size returns the approximate memory used in bytes +func (v *RequestCancelActivityTaskFailedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) // Base struct size + decisionTaskCompletedEventId + + if v.ActivityID != "" { + size += uint64(16 + len(v.ActivityID)) + } + + if v.Cause != "" { + size += uint64(16 + len(v.Cause)) + } + + return size +} + // RequestCancelExternalWorkflowExecutionDecisionAttributes is an internal type (TBD...) type RequestCancelExternalWorkflowExecutionDecisionAttributes struct { Domain string `json:"domain,omitempty"` @@ -4677,6 +5548,39 @@ func (v *RequestCancelExternalWorkflowExecutionDecisionAttributes) GetRunID() (o return } +// Size returns the approximate memory used in bytes +func (v *RequestCancelExternalWorkflowExecutionFailedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) // Base struct size + decision task and initiated event IDs + + if v.Cause != nil { + size += 8 + } + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowExecution != nil { + size += 24 // Struct overhead + if v.WorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowExecution.WorkflowID)) + } + if v.WorkflowExecution.RunID != "" { + size += uint64(16 + len(v.WorkflowExecution.RunID)) + } + } + + if v.Control != nil { + size += uint64(len(v.Control)) + } + + return size +} + // RequestCancelExternalWorkflowExecutionFailedEventAttributes is an internal type (TBD...) type RequestCancelExternalWorkflowExecutionFailedEventAttributes struct { Cause *CancelExternalWorkflowExecutionFailedCause `json:"cause,omitempty"` @@ -4711,6 +5615,35 @@ func (v *RequestCancelExternalWorkflowExecutionFailedEventAttributes) GetInitiat return } +// Size returns the approximate memory used in bytes +func (v *RequestCancelExternalWorkflowExecutionInitiatedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) // Base struct size + decisionTaskCompletedEventId + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowExecution != nil { + size += 24 // Struct overhead + if v.WorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowExecution.WorkflowID)) + } + if v.WorkflowExecution.RunID != "" { + size += uint64(16 + len(v.WorkflowExecution.RunID)) + } + } + + if v.Control != nil { + size += uint64(len(v.Control)) + } + + return size +} + // RequestCancelExternalWorkflowExecutionInitiatedEventAttributes is an internal type (TBD...) type RequestCancelExternalWorkflowExecutionInitiatedEventAttributes struct { DecisionTaskCompletedEventID int64 `json:"decisionTaskCompletedEventId,omitempty"` @@ -4786,6 +5719,11 @@ func (v *RequestCancelWorkflowExecutionRequest) GetFirstExecutionRunID() (o stri return } +// Size returns the approximate memory used in bytes +func (v *RequestCancelWorkflowExecutionRequest) Size() uint64 { + return 0 +} + // ResetPointInfo is an internal type (TBD...) type ResetPointInfo struct { BinaryChecksum string `json:"binaryChecksum,omitempty"` @@ -4844,11 +5782,21 @@ func (v *ResetPointInfo) GetResettable() (o bool) { return } +// Size returns the approximate memory used in bytes +func (v *ResetPointInfo) Size() uint64 { + return 0 +} + // ResetPoints is an internal type (TBD...) type ResetPoints struct { Points []*ResetPointInfo `json:"points,omitempty"` } +// Size returns the approximate memory used in bytes +func (v *ResetPoints) Size() uint64 { + return 0 +} + // ResetQueueRequest is an internal type (TBD...) type ResetQueueRequest struct { ShardID int32 `json:"shardID,omitempty"` @@ -4880,6 +5828,11 @@ func (v *ResetQueueRequest) GetType() (o int32) { return } +// Size returns the approximate memory used in bytes +func (v *ResetQueueRequest) Size() uint64 { + return 0 +} + // ResetStickyTaskListRequest is an internal type (TBD...) type ResetStickyTaskListRequest struct { Domain string `json:"domain,omitempty"` @@ -4902,10 +5855,20 @@ func (v *ResetStickyTaskListRequest) GetExecution() (o *WorkflowExecution) { return } +// Size returns the approximate memory used in bytes +func (v *ResetStickyTaskListRequest) Size() uint64 { + return 0 +} + // ResetStickyTaskListResponse is an internal type (TBD...) type ResetStickyTaskListResponse struct { } +// Size returns the approximate memory used in bytes +func (v *ResetStickyTaskListResponse) Size() uint64 { + return 0 +} + // ResetWorkflowExecutionRequest is an internal type (TBD...) type ResetWorkflowExecutionRequest struct { Domain string `json:"domain,omitempty"` @@ -4964,6 +5927,11 @@ func (v *ResetWorkflowExecutionRequest) GetSkipSignalReapply() (o bool) { return } +// Size returns the approximate memory used in bytes +func (v *ResetWorkflowExecutionRequest) Size() uint64 { + return 0 +} + // ResetWorkflowExecutionResponse is an internal type (TBD...) type ResetWorkflowExecutionResponse struct { RunID string `json:"runId,omitempty"` @@ -4977,6 +5945,11 @@ func (v *ResetWorkflowExecutionResponse) GetRunID() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *ResetWorkflowExecutionResponse) Size() uint64 { + return 0 +} + // RespondActivityTaskCanceledByIDRequest is an internal type (TBD...) type RespondActivityTaskCanceledByIDRequest struct { Domain string `json:"domain,omitempty"` @@ -5027,6 +6000,11 @@ func (v *RespondActivityTaskCanceledByIDRequest) GetIdentity() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *RespondActivityTaskCanceledByIDRequest) Size() uint64 { + return 0 +} + // RespondActivityTaskCanceledRequest is an internal type (TBD...) type RespondActivityTaskCanceledRequest struct { TaskToken []byte `json:"taskToken,omitempty"` @@ -5042,6 +6020,11 @@ func (v *RespondActivityTaskCanceledRequest) GetIdentity() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *RespondActivityTaskCanceledRequest) Size() uint64 { + return 0 +} + // RespondActivityTaskCompletedByIDRequest is an internal type (TBD...) type RespondActivityTaskCompletedByIDRequest struct { Domain string `json:"domain,omitempty"` @@ -5092,6 +6075,11 @@ func (v *RespondActivityTaskCompletedByIDRequest) GetIdentity() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *RespondActivityTaskCompletedByIDRequest) Size() uint64 { + return 0 +} + // RespondActivityTaskCompletedRequest is an internal type (TBD...) type RespondActivityTaskCompletedRequest struct { TaskToken []byte `json:"taskToken,omitempty"` @@ -5107,6 +6095,11 @@ func (v *RespondActivityTaskCompletedRequest) GetIdentity() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *RespondActivityTaskCompletedRequest) Size() uint64 { + return 0 +} + // RespondActivityTaskFailedByIDRequest is an internal type (TBD...) type RespondActivityTaskFailedByIDRequest struct { Domain string `json:"domain,omitempty"` @@ -5158,6 +6151,11 @@ func (v *RespondActivityTaskFailedByIDRequest) GetIdentity() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *RespondActivityTaskFailedByIDRequest) Size() uint64 { + return 0 +} + // RespondActivityTaskFailedRequest is an internal type (TBD...) type RespondActivityTaskFailedRequest struct { TaskToken []byte `json:"taskToken,omitempty"` @@ -5190,6 +6188,11 @@ func (v *RespondActivityTaskFailedRequest) GetIdentity() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *RespondActivityTaskFailedRequest) Size() uint64 { + return 0 +} + // RespondDecisionTaskCompletedRequest is an internal type (TBD...) type RespondDecisionTaskCompletedRequest struct { TaskToken []byte `json:"taskToken,omitempty"` @@ -5243,6 +6246,11 @@ func (v *RespondDecisionTaskCompletedRequest) GetQueryResults() (o map[string]*W return } +// Size returns the approximate memory used in bytes +func (v *RespondDecisionTaskCompletedRequest) Size() uint64 { + return 0 +} + // RespondDecisionTaskCompletedResponse is an internal type (TBD...) type RespondDecisionTaskCompletedResponse struct { DecisionTask *PollForDecisionTaskResponse `json:"decisionTask,omitempty"` @@ -5257,6 +6265,11 @@ func (v *RespondDecisionTaskCompletedResponse) GetDecisionTask() (o *PollForDeci return } +// Size returns the approximate memory used in bytes +func (v *RespondDecisionTaskCompletedResponse) Size() uint64 { + return 0 +} + // RespondDecisionTaskFailedRequest is an internal type (TBD...) type RespondDecisionTaskFailedRequest struct { TaskToken []byte `json:"taskToken,omitempty"` @@ -5618,6 +6631,39 @@ func (v *SignalExternalWorkflowExecutionFailedEventAttributes) GetInitiatedEvent return } +// Size returns the approximate memory used in bytes +func (v *SignalExternalWorkflowExecutionFailedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) // Base struct size + decision task and initiated event IDs + + if v.Cause != nil { + size += 8 + } + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowExecution != nil { + size += 24 // Struct overhead + if v.WorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowExecution.WorkflowID)) + } + if v.WorkflowExecution.RunID != "" { + size += uint64(16 + len(v.WorkflowExecution.RunID)) + } + } + + if v.Control != nil { + size += uint64(len(v.Control)) + } + + return size +} + // SignalExternalWorkflowExecutionInitiatedEventAttributes is an internal type (TBD...) type SignalExternalWorkflowExecutionInitiatedEventAttributes struct { DecisionTaskCompletedEventID int64 `json:"decisionTaskCompletedEventId,omitempty"` @@ -5661,6 +6707,43 @@ func (v *SignalExternalWorkflowExecutionInitiatedEventAttributes) GetChildWorkfl return } +// Size returns the approximate memory used in bytes +func (v *SignalExternalWorkflowExecutionInitiatedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) // Base struct size + decisionTaskCompletedEventId + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowExecution != nil { + size += 24 // Struct overhead + if v.WorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowExecution.WorkflowID)) + } + if v.WorkflowExecution.RunID != "" { + size += uint64(16 + len(v.WorkflowExecution.RunID)) + } + } + + if v.SignalName != "" { + size += uint64(16 + len(v.SignalName)) + } + + if v.Input != nil { + size += uint64(len(v.Input)) + } + + if v.Control != nil { + size += uint64(len(v.Control)) + } + + return size +} + // SignalWithStartWorkflowExecutionRequest is an internal type (TBD...) type SignalWithStartWorkflowExecutionRequest struct { Domain string `json:"domain,omitempty"` @@ -5928,20 +7011,54 @@ type StartChildWorkflowExecutionFailedEventAttributes struct { DecisionTaskCompletedEventID int64 `json:"decisionTaskCompletedEventId,omitempty"` } -// GetDomain is an internal getter (TBD...) -func (v *StartChildWorkflowExecutionFailedEventAttributes) GetDomain() (o string) { - if v != nil { - return v.Domain +// GetDomain is an internal getter (TBD...) +func (v *StartChildWorkflowExecutionFailedEventAttributes) GetDomain() (o string) { + if v != nil { + return v.Domain + } + return +} + +// GetInitiatedEventID is an internal getter (TBD...) +func (v *StartChildWorkflowExecutionFailedEventAttributes) GetInitiatedEventID() (o int64) { + if v != nil { + return v.InitiatedEventID + } + return +} + +// Size returns the approximate memory used in bytes +func (v *StartChildWorkflowExecutionFailedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) // Base struct size + decision task and initiated event IDs + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowID)) + } + + if v.WorkflowType != nil { + size += 16 // Struct overhead + if v.WorkflowType.Name != "" { + size += uint64(16 + len(v.WorkflowType.Name)) + } } - return -} -// GetInitiatedEventID is an internal getter (TBD...) -func (v *StartChildWorkflowExecutionFailedEventAttributes) GetInitiatedEventID() (o int64) { - if v != nil { - return v.InitiatedEventID + if v.Cause != nil { + size += 8 } - return + + if v.Control != nil { + size += uint64(len(v.Control)) + } + + return size } // StartChildWorkflowExecutionInitiatedEventAttributes is an internal type (TBD...) @@ -6007,6 +7124,101 @@ func (v *StartChildWorkflowExecutionInitiatedEventAttributes) GetExecutionStartT return } +// Size returns the approximate memory used in bytes +func (v *StartChildWorkflowExecutionInitiatedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(48) // Base struct size + decisionTaskCompletedEventId + various int fields + + if v.Domain != "" { + size += uint64(16 + len(v.Domain)) + } + + if v.WorkflowID != "" { + size += uint64(16 + len(v.WorkflowID)) + } + + if v.WorkflowType != nil { + size += 16 // Struct overhead + if v.WorkflowType.Name != "" { + size += uint64(16 + len(v.WorkflowType.Name)) + } + } + + if v.TaskList != nil { + size += 16 // Struct overhead + if v.TaskList.Name != "" { + size += uint64(16 + len(v.TaskList.Name)) + } + } + + if v.Input != nil { + size += uint64(len(v.Input)) + } + + if v.ExecutionStartToCloseTimeoutSeconds != nil { + size += 8 + } + + if v.TaskStartToCloseTimeoutSeconds != nil { + size += 8 + } + + if v.ParentClosePolicy != nil { + size += 8 + } + + if v.Control != nil { + size += uint64(len(v.Control)) + } + + if v.WorkflowIDReusePolicy != nil { + size += 8 + } + + if v.RetryPolicy != nil { + size += 40 // Approximate size for retry policy struct + } + + if v.CronSchedule != "" { + size += uint64(16 + len(v.CronSchedule)) + } + + if v.Header != nil { + size += 16 + if v.Header.Fields != nil { + size += 16 + for k, v := range v.Header.Fields { + size += uint64(16 + len(k) + len(v)) + } + } + } + + if v.Memo != nil { + size += 16 + if v.Memo.Fields != nil { + size += 16 + for k, v := range v.Memo.Fields { + size += uint64(16 + len(k) + len(v)) + } + } + } + + if v.SearchAttributes != nil { + size += 16 + if v.SearchAttributes.IndexedFields != nil { + size += 16 + for k, v := range v.SearchAttributes.IndexedFields { + size += uint64(16 + len(k) + len(v)) + } + } + } + + return size +} + // StartTimeFilter is an internal type (TBD...) type StartTimeFilter struct { EarliestTime *int64 `json:"earliestTime,omitempty"` @@ -6647,6 +7859,25 @@ func (v *TimerCanceledEventAttributes) GetTimerID() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *TimerCanceledEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) // Base struct size + startedEventId + decisionTaskCompletedEventId + + if v.TimerID != "" { + size += uint64(16 + len(v.TimerID)) + } + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + return size +} + // TimerFiredEventAttributes is an internal type (TBD...) type TimerFiredEventAttributes struct { TimerID string `json:"timerId,omitempty"` @@ -6669,6 +7900,21 @@ func (v *TimerFiredEventAttributes) GetStartedEventID() (o int64) { return } +// Size returns the approximate memory used in bytes +func (v *TimerFiredEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(16) // Base struct size + startedEventId + + if v.TimerID != "" { + size += uint64(16 + len(v.TimerID)) + } + + return size +} + // TimerStartedEventAttributes is an internal type (TBD...) type TimerStartedEventAttributes struct { TimerID string `json:"timerId,omitempty"` @@ -6692,6 +7938,21 @@ func (v *TimerStartedEventAttributes) GetStartToFireTimeoutSeconds() (o int64) { return } +// Size returns the approximate memory used in bytes +func (v *TimerStartedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(24) // Base struct size + startToFireTimeoutSeconds + decisionTaskCompletedEventId + + if v.TimerID != "" { + size += uint64(16 + len(v.TimerID)) + } + + return size +} + // TransientDecisionInfo is an internal type (TBD...) type TransientDecisionInfo struct { ScheduledEvent *HistoryEvent `json:"scheduledEvent,omitempty"` @@ -6810,6 +8071,27 @@ func (v *UpsertWorkflowSearchAttributesEventAttributes) GetSearchAttributes() (o return } +// Size returns the approximate memory used in bytes +func (v *UpsertWorkflowSearchAttributesEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(16) // Base struct size + decisionTaskCompletedEventId + + if v.SearchAttributes != nil { + size += 16 + if v.SearchAttributes.IndexedFields != nil { + size += 16 + for k, v := range v.SearchAttributes.IndexedFields { + size += uint64(16 + len(k) + len(v)) + } + } + } + + return size +} + // VersionHistories is an internal type (TBD...) type VersionHistories struct { CurrentVersionHistoryIndex int32 `json:"currentVersionHistoryIndex,omitempty"` @@ -6920,12 +8202,56 @@ type WorkflowExecutionCancelRequestedEventAttributes struct { RequestID string `json:"requestId,omitempty"` } +// Size returns the approximate memory used in bytes +func (v *WorkflowExecutionCancelRequestedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(16) // Base struct size + + if v.Cause != "" { + size += uint64(16 + len(v.Cause)) + } + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + if v.ExternalWorkflowExecution != nil { + size += 24 // Struct overhead + if v.ExternalWorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.ExternalWorkflowExecution.WorkflowID)) + } + if v.ExternalWorkflowExecution.RunID != "" { + size += uint64(16 + len(v.ExternalWorkflowExecution.RunID)) + } + } + + return size +} + // WorkflowExecutionCanceledEventAttributes is an internal type (TBD...) type WorkflowExecutionCanceledEventAttributes struct { DecisionTaskCompletedEventID int64 `json:"decisionTaskCompletedEventId,omitempty"` Details []byte `json:"details,omitempty"` } +// Size returns the approximate memory used in bytes +func (v *WorkflowExecutionCanceledEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(16) // Base struct size + decisionTaskCompletedEventId + + if v.Details != nil { + size += uint64(len(v.Details)) + } + + return size +} + // WorkflowExecutionCloseStatus is an internal type (TBD...) type WorkflowExecutionCloseStatus int32 @@ -7011,6 +8337,21 @@ type WorkflowExecutionCompletedEventAttributes struct { DecisionTaskCompletedEventID int64 `json:"decisionTaskCompletedEventId,omitempty"` } +// Size returns the approximate memory used in bytes +func (v *WorkflowExecutionCompletedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(16) // Base struct size + decisionTaskCompletedEventId + + if v.Result != nil { + size += uint64(len(v.Result)) + } + + return size +} + // WorkflowExecutionConfiguration is an internal type (TBD...) type WorkflowExecutionConfiguration struct { TaskList *TaskList `json:"taskList,omitempty"` @@ -7070,6 +8411,99 @@ func (v *WorkflowExecutionContinuedAsNewEventAttributes) GetLastCompletionResult return } +// Size returns the approximate memory used in bytes +func (v *WorkflowExecutionContinuedAsNewEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(48) // Base struct size + various int fields + + if v.NewExecutionRunID != "" { + size += uint64(16 + len(v.NewExecutionRunID)) + } + + if v.WorkflowType != nil { + size += 16 // Struct overhead + if v.WorkflowType.Name != "" { + size += uint64(16 + len(v.WorkflowType.Name)) + } + } + + if v.TaskList != nil { + size += 16 // Struct overhead + if v.TaskList.Name != "" { + size += uint64(16 + len(v.TaskList.Name)) + } + } + + if v.Input != nil { + size += uint64(len(v.Input)) + } + + if v.ExecutionStartToCloseTimeoutSeconds != nil { + size += 8 + } + + if v.TaskStartToCloseTimeoutSeconds != nil { + size += 8 + } + + if v.DecisionTaskCompletedEventID != 0 { + size += 8 + } + + if v.BackoffStartIntervalInSeconds != nil { + size += 8 + } + + if v.Initiator != nil { + size += 8 + } + + if v.FailureReason != nil { + size += 8 + } + + size += uint64(len(v.FailureDetails)) + + if v.LastCompletionResult != nil { + size += uint64(len(v.LastCompletionResult)) + } + + if v.Header != nil { + size += 16 + if v.Header.Fields != nil { + size += 16 + for k, v := range v.Header.Fields { + size += uint64(16 + len(k) + len(v)) + } + } + } + + if v.Memo != nil { + size += 16 + if v.Memo.Fields != nil { + size += 16 + for k, v := range v.Memo.Fields { + size += uint64(16 + len(k) + len(v)) + } + } + } + + if v.SearchAttributes != nil { + size += 16 + if v.SearchAttributes.IndexedFields != nil { + size += 16 + for k, v := range v.SearchAttributes.IndexedFields { + size += uint64(16 + len(k) + len(v)) + } + } + } + + return size +} + // WorkflowExecutionFailedEventAttributes is an internal type (TBD...) type WorkflowExecutionFailedEventAttributes struct { Reason *string `json:"reason,omitempty"` @@ -7085,6 +8519,25 @@ func (v *WorkflowExecutionFailedEventAttributes) GetReason() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *WorkflowExecutionFailedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(16) // Base struct size + decisionTaskCompletedEventId + + if v.Reason != nil { + size += uint64(16 + len(*v.Reason)) + } + + if v.Details != nil { + size += uint64(len(v.Details)) + } + + return size +} + // WorkflowExecutionFilter is an internal type (TBD...) type WorkflowExecutionFilter struct { WorkflowID string `json:"workflowId,omitempty"` @@ -7233,6 +8686,29 @@ func (v *WorkflowExecutionSignaledEventAttributes) GetRequestID() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *WorkflowExecutionSignaledEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(16) // Base struct size + + if v.SignalName != "" { + size += uint64(16 + len(v.SignalName)) + } + + if v.Input != nil { + size += uint64(len(v.Input)) + } + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + return size +} + // WorkflowExecutionStartedEventAttributes is an internal type (TBD...) type WorkflowExecutionStartedEventAttributes struct { WorkflowType *WorkflowType `json:"workflowType,omitempty"` @@ -7410,6 +8886,127 @@ func (v *WorkflowExecutionStartedEventAttributes) GetRequestID() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *WorkflowExecutionStartedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(64) // Base struct size + various int fields + + if v.WorkflowType != nil { + size += 16 // Struct overhead + if v.WorkflowType.Name != "" { + size += uint64(16 + len(v.WorkflowType.Name)) + } + } + + if v.ParentWorkflowDomain != nil { + size += uint64(16 + len(*v.ParentWorkflowDomain)) + } + + if v.ParentWorkflowExecution != nil { + size += 24 // Struct overhead + if v.ParentWorkflowExecution.WorkflowID != "" { + size += uint64(16 + len(v.ParentWorkflowExecution.WorkflowID)) + } + if v.ParentWorkflowExecution.RunID != "" { + size += uint64(16 + len(v.ParentWorkflowExecution.RunID)) + } + } + + if v.TaskList != nil { + size += 16 // Struct overhead + if v.TaskList.Name != "" { + size += uint64(16 + len(v.TaskList.Name)) + } + } + + if v.Input != nil { + size += uint64(len(v.Input)) + } + + if v.ExecutionStartToCloseTimeoutSeconds != nil { + size += 8 + } + + if v.TaskStartToCloseTimeoutSeconds != nil { + size += 8 + } + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + if v.RequestID != "" { + size += uint64(16 + len(v.RequestID)) + } + + if v.ContinuedExecutionRunID != "" { + size += uint64(16 + len(v.ContinuedExecutionRunID)) + } + + if v.Initiator != nil { + size += 8 + } + + if v.ContinuedFailureReason != nil { + size += uint64(16 + len(*v.ContinuedFailureReason)) + } + + if v.ContinuedFailureDetails != nil { + size += uint64(len(v.ContinuedFailureDetails)) + } + + if v.LastCompletionResult != nil { + size += uint64(len(v.LastCompletionResult)) + } + + if v.CronSchedule != "" { + size += uint64(16 + len(v.CronSchedule)) + } + + if v.FirstDecisionTaskBackoffSeconds != nil { + size += 8 + } + + if v.Memo != nil { + size += 16 + if v.Memo.Fields != nil { + size += 16 + for k, v := range v.Memo.Fields { + size += uint64(16 + len(k) + len(v)) + } + } + } + + if v.SearchAttributes != nil { + size += 16 + if v.SearchAttributes.IndexedFields != nil { + size += 16 + for k, v := range v.SearchAttributes.IndexedFields { + size += uint64(16 + len(k) + len(v)) + } + } + } + + if v.PrevAutoResetPoints != nil { + size += 24 + } + + if v.Header != nil { + size += 16 + if v.Header.Fields != nil { + size += 16 + for k, v := range v.Header.Fields { + size += uint64(16 + len(k) + len(v)) + } + } + } + + return size +} + // WorkflowExecutionTerminatedEventAttributes is an internal type (TBD...) type WorkflowExecutionTerminatedEventAttributes struct { Reason string `json:"reason,omitempty"` @@ -7433,6 +9030,29 @@ func (v *WorkflowExecutionTerminatedEventAttributes) GetIdentity() (o string) { return } +// Size returns the approximate memory used in bytes +func (v *WorkflowExecutionTerminatedEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(16) // Base struct size + + if v.Reason != "" { + size += uint64(16 + len(v.Reason)) + } + + if v.Details != nil { + size += uint64(len(v.Details)) + } + + if v.Identity != "" { + size += uint64(16 + len(v.Identity)) + } + + return size +} + // WorkflowExecutionTimedOutEventAttributes is an internal type (TBD...) type WorkflowExecutionTimedOutEventAttributes struct { TimeoutType *TimeoutType `json:"timeoutType,omitempty"` @@ -7446,6 +9066,21 @@ func (v *WorkflowExecutionTimedOutEventAttributes) GetTimeoutType() (o TimeoutTy return } +// Size returns the approximate memory used in bytes +func (v *WorkflowExecutionTimedOutEventAttributes) Size() uint64 { + if v == nil { + return 0 + } + + size := uint64(16) // Base struct size + + if v.TimeoutType != nil { + size += 8 + } + + return size +} + // WorkflowIDReusePolicy is an internal type (TBD...) type WorkflowIDReusePolicy int32 diff --git a/service/history/events/cache.go b/service/history/events/cache.go index cddc154326f..257b759bd8b 100644 --- a/service/history/events/cache.go +++ b/service/history/events/cache.go @@ -28,6 +28,7 @@ import ( "github.com/uber/cadence/common" "github.com/uber/cadence/common/cache" + "github.com/uber/cadence/common/constants" "github.com/uber/cadence/common/log" "github.com/uber/cadence/common/log/tag" "github.com/uber/cadence/common/metrics" @@ -276,3 +277,11 @@ func (e *cacheImpl) getHistoryEventFromStore( return nil, errEventNotFoundInBatch } + +func (e *eventKey) Size() uint64 { + // Calculate the size of strings in bytes, we assume that all those fields are using ASCII which is 1 byte per char + size := len(e.domainID) + len(e.workflowID) + len(e.runID) + stringOverhead := 3 * constants.StringSizeOverheadBytes + // int64 is 8 bytes + return uint64(size + stringOverhead + 8) +} diff --git a/service/history/shard/context.go b/service/history/shard/context.go index 2de8984ddaa..1f7f05e07a8 100644 --- a/service/history/shard/context.go +++ b/service/history/shard/context.go @@ -116,6 +116,8 @@ type ( ReplicateFailoverMarkers(ctx context.Context, markers []*persistence.FailoverMarkerTask) error AddingPendingFailoverMarker(*types.FailoverMarkerAttributes) error ValidateAndUpdateFailoverMarkers() ([]*types.FailoverMarkerAttributes, error) + + Size() uint64 } // TransferFailoverLevel contains corresponding start / end level @@ -1414,6 +1416,11 @@ func (s *contextImpl) ValidateAndUpdateFailoverMarkers() ([]*types.FailoverMarke return s.shardInfo.PendingFailoverMarkers, nil } +func (s *contextImpl) Size() uint64 { + // TODO: To be implemented + return 0 +} + func acquireShard( shardItem *historyShardsItem, closeCallback func(int, *historyShardsItem), diff --git a/service/history/shard/context_mock.go b/service/history/shard/context_mock.go index 1da5a87dd57..59fc614aa86 100644 --- a/service/history/shard/context_mock.go +++ b/service/history/shard/context_mock.go @@ -637,6 +637,20 @@ func (mr *MockContextMockRecorder) SetEngine(arg0 any) *gomock.Call { return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "SetEngine", reflect.TypeOf((*MockContext)(nil).SetEngine), arg0) } +// Size mocks base method. +func (m *MockContext) Size() uint64 { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "Size") + ret0, _ := ret[0].(uint64) + return ret0 +} + +// Size indicates an expected call of Size. +func (mr *MockContextMockRecorder) Size() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Size", reflect.TypeOf((*MockContext)(nil).Size)) +} + // UpdateClusterReplicationLevel mocks base method. func (m *MockContext) UpdateClusterReplicationLevel(cluster string, lastTaskID int64) error { m.ctrl.T.Helper()