Skip to content

Commit

Permalink
Revert "Drop pointer on ActivityTaskScheduledEventAttributes.Domain (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
yycptt authored Mar 29, 2021
1 parent 480cf5e commit d070b9d
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion common/testing/history_event_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func InitializeHistoryEventGenerator(
ActivityType: &types.ActivityType{
Name: "activity",
},
Domain: domain,
Domain: common.StringPtr(domain),
TaskList: &types.TaskList{
Name: taskList,
Kind: types.TaskListKindNormal.Ptr(),
Expand Down
4 changes: 2 additions & 2 deletions common/types/mapper/proto/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func FromActivityTaskScheduledEventAttributes(t *types.ActivityTaskScheduledEven
return &apiv1.ActivityTaskScheduledEventAttributes{
ActivityId: t.ActivityID,
ActivityType: FromActivityType(t.ActivityType),
Domain: t.Domain,
Domain: t.GetDomain(),
TaskList: FromTaskList(t.TaskList),
Input: FromPayload(t.Input),
ScheduleToCloseTimeout: secondsToDuration(t.ScheduleToCloseTimeoutSeconds),
Expand All @@ -174,7 +174,7 @@ func ToActivityTaskScheduledEventAttributes(t *apiv1.ActivityTaskScheduledEventA
return &types.ActivityTaskScheduledEventAttributes{
ActivityID: t.ActivityId,
ActivityType: ToActivityType(t.ActivityType),
Domain: t.Domain,
Domain: &t.Domain,
TaskList: ToTaskList(t.TaskList),
Input: ToPayload(t.Input),
ScheduleToCloseTimeoutSeconds: durationToSeconds(t.ScheduleToCloseTimeout),
Expand Down
4 changes: 3 additions & 1 deletion common/types/mapper/proto/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ func TestActivityTaskFailedEventAttributes(t *testing.T) {
}
}
func TestActivityTaskScheduledEventAttributes(t *testing.T) {
for _, item := range []*types.ActivityTaskScheduledEventAttributes{nil, {}, &testdata.ActivityTaskScheduledEventAttributes} {
// since proto definition for Domain field doesn't have pointer, To(From(item)) won't be equal to item when item's Domain is a nil pointer
// this is fine as the code using this field will check both if the field is a nil pointer and if it's a pointer to an empty string.
for _, item := range []*types.ActivityTaskScheduledEventAttributes{nil, {Domain: common.StringPtr("")}, &testdata.ActivityTaskScheduledEventAttributes} {
assert.Equal(t, item, ToActivityTaskScheduledEventAttributes(FromActivityTaskScheduledEventAttributes(item)))
}
}
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 @@ -186,7 +186,7 @@ func FromActivityTaskScheduledEventAttributes(t *types.ActivityTaskScheduledEven
return &shared.ActivityTaskScheduledEventAttributes{
ActivityId: &t.ActivityID,
ActivityType: FromActivityType(t.ActivityType),
Domain: &t.Domain,
Domain: t.Domain,
TaskList: FromTaskList(t.TaskList),
Input: t.Input,
ScheduleToCloseTimeoutSeconds: t.ScheduleToCloseTimeoutSeconds,
Expand All @@ -207,7 +207,7 @@ func ToActivityTaskScheduledEventAttributes(t *shared.ActivityTaskScheduledEvent
return &types.ActivityTaskScheduledEventAttributes{
ActivityID: t.GetActivityId(),
ActivityType: ToActivityType(t.ActivityType),
Domain: t.GetDomain(),
Domain: t.Domain,
TaskList: ToTaskList(t.TaskList),
Input: t.Input,
ScheduleToCloseTimeoutSeconds: t.ScheduleToCloseTimeoutSeconds,
Expand Down
6 changes: 3 additions & 3 deletions common/types/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (v *ActivityTaskFailedEventAttributes) GetIdentity() (o string) {
type ActivityTaskScheduledEventAttributes struct {
ActivityID string `json:"activityId,omitempty"`
ActivityType *ActivityType `json:"activityType,omitempty"`
Domain string `json:"domain,omitempty"`
Domain *string `json:"domain,omitempty"`
TaskList *TaskList `json:"taskList,omitempty"`
Input []byte `json:"input,omitempty"`
ScheduleToCloseTimeoutSeconds *int32 `json:"scheduleToCloseTimeoutSeconds,omitempty"`
Expand Down Expand Up @@ -282,8 +282,8 @@ func (v *ActivityTaskScheduledEventAttributes) GetActivityType() (o *ActivityTyp

// GetDomain is an internal getter (TBD...)
func (v *ActivityTaskScheduledEventAttributes) GetDomain() (o string) {
if v != nil {
return v.Domain
if v != nil && v.Domain != nil {
return *v.Domain
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion common/types/testdata/history.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ var (
ActivityTaskScheduledEventAttributes = types.ActivityTaskScheduledEventAttributes{
ActivityID: ActivityID,
ActivityType: &ActivityType,
Domain: DomainName,
Domain: common.StringPtr(DomainName),
TaskList: &TaskList,
Input: Payload1,
ScheduleToCloseTimeoutSeconds: &Duration1,
Expand Down
2 changes: 1 addition & 1 deletion service/history/execution/mutable_state_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2150,7 +2150,7 @@ func (e *mutableStateBuilder) ReplicateActivityTaskScheduledEvent(

attributes := event.ActivityTaskScheduledEventAttributes
targetDomainID := e.executionInfo.DomainID
if attributes.Domain != "" {
if attributes.GetDomain() != "" {
targetDomainEntry, err := e.shard.GetDomainCache().GetDomain(attributes.GetDomain())
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion service/history/execution/state_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (b *stateBuilderImpl) ApplyEvents(
// as ParentWorkflowDomainID will not be present on older histories.
if attributes.ParentWorkflowDomainID != nil {
parentDomainID = attributes.ParentWorkflowDomainID
} else if attributes.ParentWorkflowDomain != nil {
} else if attributes.GetParentWorkflowDomain() != "" {
parentDomainEntry, err := b.domainCache.GetDomain(
attributes.GetParentWorkflowDomain(),
)
Expand Down
2 changes: 1 addition & 1 deletion service/history/task/timer_active_task_executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,7 @@ func (t *timerActiveTaskExecutor) executeActivityRetryTimerTask(
if err != nil {
return err
}
if scheduledEvent.ActivityTaskScheduledEventAttributes.Domain != "" {
if scheduledEvent.ActivityTaskScheduledEventAttributes.GetDomain() != "" {
domainEntry, err := t.shard.GetDomainCache().GetDomain(scheduledEvent.ActivityTaskScheduledEventAttributes.GetDomain())
if err != nil {
return &types.InternalServiceError{Message: "unable to re-schedule activity across domain."}
Expand Down

0 comments on commit d070b9d

Please sign in to comment.