Skip to content

Commit 167c85a

Browse files
authored
Revert "Revert "Plumb through workflow type into client (#590)" (#594)" (#595)
This reverts commit ffeb969.
1 parent ffeb969 commit 167c85a

File tree

5 files changed

+31
-5
lines changed

5 files changed

+31
-5
lines changed

idl/github.com/uber/cadence/shared.thrift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -945,6 +945,8 @@ struct PollForActivityTaskResponse {
945945
120: optional i32 attempt
946946
130: optional i64 (js.type = "Long") scheduledTimestampOfThisAttempt
947947
140: optional binary heartbeatDetails
948+
150: optional WorkflowType workflowType
949+
160: optional string workflowDomain
948950
}
949951

950952
struct RecordActivityTaskHeartbeatRequest {

internal/activity.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ type (
4040
// ActivityInfo contains information about currently executing activity.
4141
ActivityInfo struct {
4242
TaskToken []byte
43+
WorkflowType *WorkflowType
44+
WorkflowDomain string
4345
WorkflowExecution WorkflowExecution
4446
ActivityID string
4547
ActivityType ActivityType
@@ -161,6 +163,8 @@ func GetActivityInfo(ctx context.Context) ActivityInfo {
161163
StartedTimestamp: env.startedTimestamp,
162164
TaskList: env.taskList,
163165
Attempt: env.attempt,
166+
WorkflowType: env.workflowType,
167+
WorkflowDomain: env.workflowDomain,
164168
}
165169
}
166170

@@ -277,6 +281,10 @@ func WithActivityTask(
277281
dataConverter: dataConverter,
278282
attempt: task.GetAttempt(),
279283
heartbeatDetails: task.HeartbeatDetails,
284+
workflowType: &WorkflowType{
285+
Name: *task.WorkflowType.Name,
286+
},
287+
workflowDomain: *task.WorkflowDomain,
280288
})
281289
}
282290

internal/internal_activity.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ type (
125125
dataConverter encoded.DataConverter
126126
attempt int32 // starts from 0.
127127
heartbeatDetails []byte
128+
workflowType *WorkflowType
129+
workflowDomain string
128130
}
129131

130132
// context.WithValue need this type instead of basic type string to avoid lint error

internal/internal_task_handlers_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,6 +666,10 @@ func (t *TaskHandlersTestSuite) TestActivityExecutionDeadline() {
666666
ScheduleToCloseTimeoutSeconds: common.Int32Ptr(d.ScheduleDuration),
667667
StartedTimestamp: common.Int64Ptr(d.StartTS.UnixNano()),
668668
StartToCloseTimeoutSeconds: common.Int32Ptr(d.StartDuration),
669+
WorkflowType: &s.WorkflowType{
670+
Name: common.StringPtr("wType"),
671+
},
672+
WorkflowDomain: common.StringPtr("domain"),
669673
}
670674
td := fmt.Sprintf("testIndex: %v, testDetails: %v", i, d)
671675
r, err := activityHandler.Execute(tasklist, pats)

internal/internal_workflow_testsuite.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,12 @@ import (
4444
)
4545

4646
const (
47-
defaultTestDomain = "default-test-domain"
48-
defaultTestTaskList = "default-test-tasklist"
49-
defaultTestWorkflowID = "default-test-workflow-id"
50-
defaultTestRunID = "default-test-run-id"
47+
defaultTestDomain = "default-test-domain"
48+
defaultTestTaskList = "default-test-tasklist"
49+
defaultTestWorkflowID = "default-test-workflow-id"
50+
defaultTestRunID = "default-test-run-id"
51+
defaultTestWorkflowTypeName = "default-test-workflow-type-name"
52+
defaultTestDomainName = "default-test-domain-name"
5153
)
5254

5355
type (
@@ -439,6 +441,8 @@ func (env *testWorkflowEnvironmentImpl) executeActivity(
439441
defaultTestWorkflowID,
440442
defaultTestRunID,
441443
"0",
444+
defaultTestWorkflowTypeName,
445+
defaultTestDomainName,
442446
params,
443447
)
444448

@@ -803,6 +807,8 @@ func (env *testWorkflowEnvironmentImpl) ExecuteActivity(parameters executeActivi
803807
defaultTestWorkflowID,
804808
defaultTestRunID,
805809
activityInfo.activityID,
810+
defaultTestWorkflowTypeName,
811+
defaultTestDomainName,
806812
parameters,
807813
)
808814

@@ -1365,7 +1371,7 @@ func (env *testWorkflowEnvironmentImpl) newTestActivityTaskHandler(taskList stri
13651371
return taskHandler
13661372
}
13671373

1368-
func newTestActivityTask(workflowID, runID, activityID string, params executeActivityParams) *shared.PollForActivityTaskResponse {
1374+
func newTestActivityTask(workflowID, runID, activityID, workflowTypeName, domainName string, params executeActivityParams) *shared.PollForActivityTaskResponse {
13691375
task := &shared.PollForActivityTaskResponse{
13701376
WorkflowExecution: &shared.WorkflowExecution{
13711377
WorkflowId: common.StringPtr(workflowID),
@@ -1380,6 +1386,10 @@ func newTestActivityTask(workflowID, runID, activityID string, params executeAct
13801386
StartedTimestamp: common.Int64Ptr(time.Now().UnixNano()),
13811387
StartToCloseTimeoutSeconds: common.Int32Ptr(params.StartToCloseTimeoutSeconds),
13821388
HeartbeatTimeoutSeconds: common.Int32Ptr(params.HeartbeatTimeoutSeconds),
1389+
WorkflowType: &shared.WorkflowType{
1390+
Name: common.StringPtr(workflowTypeName),
1391+
},
1392+
WorkflowDomain: common.StringPtr(domainName),
13831393
}
13841394
return task
13851395
}

0 commit comments

Comments
 (0)