Skip to content

Commit

Permalink
Drop pointer for task id fields (cadence-workflow#3969)
Browse files Browse the repository at this point in the history
  • Loading branch information
vytautas-karpavicius authored Feb 17, 2021
1 parent 523edce commit baf151a
Show file tree
Hide file tree
Showing 22 changed files with 85 additions and 86 deletions.
2 changes: 1 addition & 1 deletion common/domain/dlqMessageHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (d *dlqMessageHandlerImpl) Merge(
); err != nil {
return nil, err
}
ackedMessageID = *message.SourceTaskID
ackedMessageID = message.SourceTaskID
}

if err := d.replicationQueue.RangeDeleteMessagesFromDLQ(
Expand Down
18 changes: 9 additions & 9 deletions common/domain/dlqMessageHandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (s *dlqMessageHandlerSuite) TestReadMessages() {
tasks := []*types.ReplicationTask{
{
TaskType: types.ReplicationTaskTypeDomain.Ptr(),
SourceTaskID: common.Int64Ptr(1),
SourceTaskID: 1,
},
}
s.mockReplicationQueue.EXPECT().GetDLQAckLevel(gomock.Any()).Return(ackLevel, nil).Times(1)
Expand All @@ -112,7 +112,7 @@ func (s *dlqMessageHandlerSuite) TestReadMessages_ThrowErrorOnGetDLQAckLevel() {
tasks := []*types.ReplicationTask{
{
TaskType: types.ReplicationTaskTypeDomain.Ptr(),
SourceTaskID: common.Int64Ptr(1),
SourceTaskID: 1,
},
}
testError := fmt.Errorf("test")
Expand Down Expand Up @@ -192,7 +192,7 @@ func (s *dlqMessageHandlerSuite) TestMergeMessages() {
tasks := []*types.ReplicationTask{
{
TaskType: types.ReplicationTaskTypeDomain.Ptr(),
SourceTaskID: common.Int64Ptr(messageID),
SourceTaskID: messageID,
DomainTaskAttributes: domainAttribute,
},
}
Expand Down Expand Up @@ -221,7 +221,7 @@ func (s *dlqMessageHandlerSuite) TestMergeMessages_ThrowErrorOnGetDLQAckLevel()
tasks := []*types.ReplicationTask{
{
TaskType: types.ReplicationTaskTypeDomain.Ptr(),
SourceTaskID: common.Int64Ptr(int64(messageID)),
SourceTaskID: messageID,
DomainTaskAttributes: domainAttribute,
},
}
Expand Down Expand Up @@ -273,12 +273,12 @@ func (s *dlqMessageHandlerSuite) TestMergeMessages_ThrowErrorOnHandleReceivingTa
tasks := []*types.ReplicationTask{
{
TaskType: types.ReplicationTaskTypeDomain.Ptr(),
SourceTaskID: common.Int64Ptr(messageID1),
SourceTaskID: messageID1,
DomainTaskAttributes: domainAttribute1,
},
{
TaskType: types.ReplicationTaskTypeDomain.Ptr(),
SourceTaskID: common.Int64Ptr(messageID2),
SourceTaskID: messageID2,
DomainTaskAttributes: domainAttribute2,
},
}
Expand Down Expand Up @@ -313,12 +313,12 @@ func (s *dlqMessageHandlerSuite) TestMergeMessages_ThrowErrorOnDeleteMessages()
tasks := []*types.ReplicationTask{
{
TaskType: types.ReplicationTaskTypeDomain.Ptr(),
SourceTaskID: common.Int64Ptr(messageID1),
SourceTaskID: messageID1,
DomainTaskAttributes: domainAttribute1,
},
{
TaskType: types.ReplicationTaskTypeDomain.Ptr(),
SourceTaskID: common.Int64Ptr(messageID2),
SourceTaskID: messageID2,
DomainTaskAttributes: domainAttribute2,
},
}
Expand Down Expand Up @@ -349,7 +349,7 @@ func (s *dlqMessageHandlerSuite) TestMergeMessages_IgnoreErrorOnUpdateDLQAckLeve
tasks := []*types.ReplicationTask{
{
TaskType: types.ReplicationTaskTypeDomain.Ptr(),
SourceTaskID: common.Int64Ptr(messageID),
SourceTaskID: messageID,
DomainTaskAttributes: domainAttribute,
},
}
Expand Down
2 changes: 1 addition & 1 deletion common/testing/history_event_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ func getDefaultHistoryEvent(
return &types.HistoryEvent{
EventID: EventID,
Timestamp: common.Int64Ptr(time.Now().UnixNano()),
TaskID: common.Int64Ptr(globalTaskID),
TaskID: globalTaskID,
Version: version,
}
}
Expand Down
12 changes: 6 additions & 6 deletions common/types/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ type RecordActivityTaskStartedRequest struct {
DomainUUID string `json:"domainUUID,omitempty"`
WorkflowExecution *WorkflowExecution `json:"workflowExecution,omitempty"`
ScheduleID *int64 `json:"scheduleId,omitempty"`
TaskID *int64 `json:"taskId,omitempty"`
TaskID int64 `json:"taskId,omitempty"`
RequestID string `json:"requestId,omitempty"`
PollRequest *PollForActivityTaskRequest `json:"pollRequest,omitempty"`
}
Expand Down Expand Up @@ -749,8 +749,8 @@ func (v *RecordActivityTaskStartedRequest) GetScheduleID() (o int64) {

// GetTaskID is an internal getter (TBD...)
func (v *RecordActivityTaskStartedRequest) GetTaskID() (o int64) {
if v != nil && v.TaskID != nil {
return *v.TaskID
if v != nil {
return v.TaskID
}
return
}
Expand Down Expand Up @@ -892,7 +892,7 @@ type RecordDecisionTaskStartedRequest struct {
DomainUUID string `json:"domainUUID,omitempty"`
WorkflowExecution *WorkflowExecution `json:"workflowExecution,omitempty"`
ScheduleID *int64 `json:"scheduleId,omitempty"`
TaskID *int64 `json:"taskId,omitempty"`
TaskID int64 `json:"taskId,omitempty"`
RequestID string `json:"requestId,omitempty"`
PollRequest *PollForDecisionTaskRequest `json:"pollRequest,omitempty"`
}
Expand Down Expand Up @@ -923,8 +923,8 @@ func (v *RecordDecisionTaskStartedRequest) GetScheduleID() (o int64) {

// GetTaskID is an internal getter (TBD...)
func (v *RecordDecisionTaskStartedRequest) GetTaskID() (o int64) {
if v != nil && v.TaskID != nil {
return *v.TaskID
if v != nil {
return v.TaskID
}
return
}
Expand Down
8 changes: 4 additions & 4 deletions common/types/mapper/thrift/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ func FromRecordActivityTaskStartedRequest(t *types.RecordActivityTaskStartedRequ
DomainUUID: &t.DomainUUID,
WorkflowExecution: FromWorkflowExecution(t.WorkflowExecution),
ScheduleId: t.ScheduleID,
TaskId: t.TaskID,
TaskId: &t.TaskID,
RequestId: &t.RequestID,
PollRequest: FromPollForActivityTaskRequest(t.PollRequest),
}
Expand All @@ -512,7 +512,7 @@ func ToRecordActivityTaskStartedRequest(t *history.RecordActivityTaskStartedRequ
DomainUUID: t.GetDomainUUID(),
WorkflowExecution: ToWorkflowExecution(t.WorkflowExecution),
ScheduleID: t.ScheduleId,
TaskID: t.TaskId,
TaskID: t.GetTaskId(),
RequestID: t.GetRequestId(),
PollRequest: ToPollForActivityTaskRequest(t.PollRequest),
}
Expand Down Expand Up @@ -587,7 +587,7 @@ func FromRecordDecisionTaskStartedRequest(t *types.RecordDecisionTaskStartedRequ
DomainUUID: &t.DomainUUID,
WorkflowExecution: FromWorkflowExecution(t.WorkflowExecution),
ScheduleId: t.ScheduleID,
TaskId: t.TaskID,
TaskId: &t.TaskID,
RequestId: &t.RequestID,
PollRequest: FromPollForDecisionTaskRequest(t.PollRequest),
}
Expand All @@ -602,7 +602,7 @@ func ToRecordDecisionTaskStartedRequest(t *history.RecordDecisionTaskStartedRequ
DomainUUID: t.GetDomainUUID(),
WorkflowExecution: ToWorkflowExecution(t.WorkflowExecution),
ScheduleID: t.ScheduleId,
TaskID: t.TaskId,
TaskID: t.GetTaskId(),
RequestID: t.GetRequestId(),
PollRequest: ToPollForDecisionTaskRequest(t.PollRequest),
}
Expand Down
4 changes: 2 additions & 2 deletions common/types/mapper/thrift/matching.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func FromMatchingRespondQueryTaskCompletedRequest(t *types.MatchingRespondQueryT
return &matching.RespondQueryTaskCompletedRequest{
DomainUUID: &t.DomainUUID,
TaskList: FromTaskList(t.TaskList),
TaskID: t.TaskID,
TaskID: &t.TaskID,
CompletedRequest: FromRespondQueryTaskCompletedRequest(t.CompletedRequest),
}
}
Expand All @@ -313,7 +313,7 @@ func ToMatchingRespondQueryTaskCompletedRequest(t *matching.RespondQueryTaskComp
return &types.MatchingRespondQueryTaskCompletedRequest{
DomainUUID: t.GetDomainUUID(),
TaskList: ToTaskList(t.TaskList),
TaskID: t.TaskID,
TaskID: t.GetTaskID(),
CompletedRequest: ToRespondQueryTaskCompletedRequest(t.CompletedRequest),
}
}
Expand Down
12 changes: 6 additions & 6 deletions common/types/mapper/thrift/replicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ func FromHistoryTaskV2Attributes(t *types.HistoryTaskV2Attributes) *replicator.H
return nil
}
return &replicator.HistoryTaskV2Attributes{
TaskId: t.TaskID,
TaskId: &t.TaskID,
DomainId: &t.DomainID,
WorkflowId: &t.WorkflowID,
RunId: &t.RunID,
Expand All @@ -316,7 +316,7 @@ func ToHistoryTaskV2Attributes(t *replicator.HistoryTaskV2Attributes) *types.His
return nil
}
return &types.HistoryTaskV2Attributes{
TaskID: t.TaskId,
TaskID: t.GetTaskId(),
DomainID: t.GetDomainId(),
WorkflowID: t.GetWorkflowId(),
RunID: t.GetRunId(),
Expand Down Expand Up @@ -491,7 +491,7 @@ func FromReplicationTask(t *types.ReplicationTask) *replicator.ReplicationTask {
}
return &replicator.ReplicationTask{
TaskType: FromReplicationTaskType(t.TaskType),
SourceTaskId: t.SourceTaskID,
SourceTaskId: &t.SourceTaskID,
DomainTaskAttributes: FromDomainTaskAttributes(t.DomainTaskAttributes),
SyncShardStatusTaskAttributes: FromSyncShardStatusTaskAttributes(t.SyncShardStatusTaskAttributes),
SyncActivityTaskAttributes: FromSyncActivityTaskAttributes(t.SyncActivityTaskAttributes),
Expand All @@ -508,7 +508,7 @@ func ToReplicationTask(t *replicator.ReplicationTask) *types.ReplicationTask {
}
return &types.ReplicationTask{
TaskType: ToReplicationTaskType(t.TaskType),
SourceTaskID: t.SourceTaskId,
SourceTaskID: t.GetSourceTaskId(),
DomainTaskAttributes: ToDomainTaskAttributes(t.DomainTaskAttributes),
SyncShardStatusTaskAttributes: ToSyncShardStatusTaskAttributes(t.SyncShardStatusTaskAttributes),
SyncActivityTaskAttributes: ToSyncActivityTaskAttributes(t.SyncActivityTaskAttributes),
Expand All @@ -528,7 +528,7 @@ func FromReplicationTaskInfo(t *types.ReplicationTaskInfo) *replicator.Replicati
WorkflowID: &t.WorkflowID,
RunID: &t.RunID,
TaskType: t.TaskType,
TaskID: t.TaskID,
TaskID: &t.TaskID,
Version: t.Version,
FirstEventID: t.FirstEventID,
NextEventID: t.NextEventID,
Expand All @@ -546,7 +546,7 @@ func ToReplicationTaskInfo(t *replicator.ReplicationTaskInfo) *types.Replication
WorkflowID: t.GetWorkflowID(),
RunID: t.GetRunID(),
TaskType: t.TaskType,
TaskID: t.TaskID,
TaskID: t.GetTaskID(),
Version: t.Version,
FirstEventID: t.FirstEventID,
NextEventID: t.NextEventID,
Expand Down
4 changes: 2 additions & 2 deletions common/types/mapper/thrift/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -2492,7 +2492,7 @@ func FromHistoryEvent(t *types.HistoryEvent) *shared.HistoryEvent {
Timestamp: t.Timestamp,
EventType: FromEventType(t.EventType),
Version: &t.Version,
TaskId: t.TaskID,
TaskId: &t.TaskID,
WorkflowExecutionStartedEventAttributes: FromWorkflowExecutionStartedEventAttributes(t.WorkflowExecutionStartedEventAttributes),
WorkflowExecutionCompletedEventAttributes: FromWorkflowExecutionCompletedEventAttributes(t.WorkflowExecutionCompletedEventAttributes),
WorkflowExecutionFailedEventAttributes: FromWorkflowExecutionFailedEventAttributes(t.WorkflowExecutionFailedEventAttributes),
Expand Down Expand Up @@ -2548,7 +2548,7 @@ func ToHistoryEvent(t *shared.HistoryEvent) *types.HistoryEvent {
Timestamp: t.Timestamp,
EventType: ToEventType(t.EventType),
Version: t.GetVersion(),
TaskID: t.TaskId,
TaskID: t.GetTaskId(),
WorkflowExecutionStartedEventAttributes: ToWorkflowExecutionStartedEventAttributes(t.WorkflowExecutionStartedEventAttributes),
WorkflowExecutionCompletedEventAttributes: ToWorkflowExecutionCompletedEventAttributes(t.WorkflowExecutionCompletedEventAttributes),
WorkflowExecutionFailedEventAttributes: ToWorkflowExecutionFailedEventAttributes(t.WorkflowExecutionFailedEventAttributes),
Expand Down
6 changes: 3 additions & 3 deletions common/types/matching.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ func (v *MatchingQueryWorkflowRequest) GetForwardedFrom() (o string) {
type MatchingRespondQueryTaskCompletedRequest struct {
DomainUUID string `json:"domainUUID,omitempty"`
TaskList *TaskList `json:"taskList,omitempty"`
TaskID *string `json:"taskID,omitempty"`
TaskID string `json:"taskID,omitempty"`
CompletedRequest *RespondQueryTaskCompletedRequest `json:"completedRequest,omitempty"`
}

Expand All @@ -556,8 +556,8 @@ func (v *MatchingRespondQueryTaskCompletedRequest) GetTaskList() (o *TaskList) {

// GetTaskID is an internal getter (TBD...)
func (v *MatchingRespondQueryTaskCompletedRequest) GetTaskID() (o string) {
if v != nil && v.TaskID != nil {
return *v.TaskID
if v != nil {
return v.TaskID
}
return
}
Expand Down
18 changes: 9 additions & 9 deletions common/types/replicator.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func (v *GetReplicationMessagesResponse) GetMessagesByShard() (o map[int32]*Repl

// HistoryTaskV2Attributes is an internal type (TBD...)
type HistoryTaskV2Attributes struct {
TaskID *int64 `json:"taskId,omitempty"`
TaskID int64 `json:"taskId,omitempty"`
DomainID string `json:"domainId,omitempty"`
WorkflowID string `json:"workflowId,omitempty"`
RunID string `json:"runId,omitempty"`
Expand All @@ -366,8 +366,8 @@ type HistoryTaskV2Attributes struct {

// GetTaskID is an internal getter (TBD...)
func (v *HistoryTaskV2Attributes) GetTaskID() (o int64) {
if v != nil && v.TaskID != nil {
return *v.TaskID
if v != nil {
return v.TaskID
}
return
}
Expand Down Expand Up @@ -672,7 +672,7 @@ func (v *ReplicationMessages) GetSyncShardStatus() (o *SyncShardStatus) {
// ReplicationTask is an internal type (TBD...)
type ReplicationTask struct {
TaskType *ReplicationTaskType `json:"taskType,omitempty"`
SourceTaskID *int64 `json:"sourceTaskId,omitempty"`
SourceTaskID int64 `json:"sourceTaskId,omitempty"`
DomainTaskAttributes *DomainTaskAttributes `json:"domainTaskAttributes,omitempty"`
SyncShardStatusTaskAttributes *SyncShardStatusTaskAttributes `json:"syncShardStatusTaskAttributes,omitempty"`
SyncActivityTaskAttributes *SyncActivityTaskAttributes `json:"syncActivityTaskAttributes,omitempty"`
Expand All @@ -691,8 +691,8 @@ func (v *ReplicationTask) GetTaskType() (o ReplicationTaskType) {

// GetSourceTaskID is an internal getter (TBD...)
func (v *ReplicationTask) GetSourceTaskID() (o int64) {
if v != nil && v.SourceTaskID != nil {
return *v.SourceTaskID
if v != nil {
return v.SourceTaskID
}
return
}
Expand Down Expand Up @@ -751,7 +751,7 @@ type ReplicationTaskInfo struct {
WorkflowID string `json:"workflowID,omitempty"`
RunID string `json:"runID,omitempty"`
TaskType *int16 `json:"taskType,omitempty"`
TaskID *int64 `json:"taskID,omitempty"`
TaskID int64 `json:"taskID,omitempty"`
Version *int64 `json:"version,omitempty"`
FirstEventID *int64 `json:"firstEventID,omitempty"`
NextEventID *int64 `json:"nextEventID,omitempty"`
Expand Down Expand Up @@ -792,8 +792,8 @@ func (v *ReplicationTaskInfo) GetTaskType() (o int16) {

// GetTaskID is an internal getter (TBD...)
func (v *ReplicationTaskInfo) GetTaskID() (o int64) {
if v != nil && v.TaskID != nil {
return *v.TaskID
if v != nil {
return v.TaskID
}
return
}
Expand Down
6 changes: 3 additions & 3 deletions common/types/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -3600,7 +3600,7 @@ type HistoryEvent struct {
Timestamp *int64 `json:"timestamp,omitempty"`
EventType *EventType `json:"eventType,omitempty"`
Version int64 `json:"version,omitempty"`
TaskID *int64 `json:"taskId,omitempty"`
TaskID int64 `json:"taskId,omitempty"`
WorkflowExecutionStartedEventAttributes *WorkflowExecutionStartedEventAttributes `json:"workflowExecutionStartedEventAttributes,omitempty"`
WorkflowExecutionCompletedEventAttributes *WorkflowExecutionCompletedEventAttributes `json:"workflowExecutionCompletedEventAttributes,omitempty"`
WorkflowExecutionFailedEventAttributes *WorkflowExecutionFailedEventAttributes `json:"workflowExecutionFailedEventAttributes,omitempty"`
Expand Down Expand Up @@ -3679,8 +3679,8 @@ func (v *HistoryEvent) GetVersion() (o int64) {

// GetTaskID is an internal getter (TBD...)
func (v *HistoryEvent) GetTaskID() (o int64) {
if v != nil && v.TaskID != nil {
return *v.TaskID
if v != nil {
return v.TaskID
}
return
}
Expand Down
Loading

0 comments on commit baf151a

Please sign in to comment.