-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Standalone Activity List and Count ActivityExecutions #8789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: standalone-activity
Are you sure you want to change the base?
Conversation
601fb05 to
65cb249
Compare
e349308 to
dbdead0
Compare
c06d36b to
155925e
Compare
| const ( | ||
| ActivityTypeSAAlias = "ActivityType" | ||
| ActivityStatusSAAlias = "ActivityStatus" | ||
| ActivityTaskQueueSAAlias = "ActivityTaskQueue" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ActivityTaskQueueSAAlias = "ActivityTaskQueue" | |
| TaskQueueSAAlias = "TaskQueue" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, it's just task queue.
| "google.golang.org/protobuf/types/known/durationpb" | ||
| "google.golang.org/protobuf/types/known/timestamppb" | ||
| ) | ||
|
|
||
| const ( | ||
| ActivityTypeSAAlias = "ActivityType" | ||
| ActivityStatusSAAlias = "ActivityStatus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| ActivityStatusSAAlias = "ActivityStatus" | |
| ActivityStatusSAAlias = "ExecutionStatus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the same non-qualified name as workflows.
| ActivityTypeSearchAttribute = chasm.NewSearchAttributeKeyword(ActivityTypeSAAlias, chasm.SearchAttributeFieldKeyword01) | ||
| ActivityStatusSearchAttribute = chasm.NewSearchAttributeKeyword(ActivityStatusSAAlias, chasm.SearchAttributeFieldLowCardinalityKeyword01) | ||
| ActivityTaskQueueSearchAttribute = chasm.NewSearchAttributeKeyword(ActivityTaskQueueSAAlias, chasm.SearchAttributeFieldKeyword02) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be totally okay if we didn't stutter here and omitted the Activity prefix from these variables. We're already in the activity package.
| if err != nil { | ||
| return nil, err | ||
| } | ||
| ctx = chasm.NewVisibilityManagerContext(ctx, h.visibilityManager) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is something that we expect to be done in an interceptor. Please coordinate with @awln-temporal @lina-temporal and @rodrigozhou on this.
| @@ -238,6 +325,21 @@ func (h *frontendHandler) validateAndPopulateStartRequest( | |||
| } | |||
| applyActivityOptionsToStartRequest(opts, req) | |||
|
|
|||
| // TODO: Unalias for validation, then restore aliased SA for CHASM visibility storage. The | |||
| // validator requires unaliased format but CHASM visibility expects aliased format. | |||
| originalSA := req.SearchAttributes | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would make validateAndNormalizeStartActivityExecutionRequest a method of the handler and unalias in there. Seems cleaner than mutating the request twice.
| @@ -38,6 +38,12 @@ func ResolveSearchAttributeAlias( | |||
| return sadefs.WorkflowID, saType, nil | |||
| } | |||
|
|
|||
| // Handle ActivityId → WorkflowID transformation for standalone activities | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Visibility team should fix the need to hardcode here eventually. Add a TODO.
| @@ -59,6 +59,8 @@ const ( | |||
| // any other custom search attribute. | |||
| ScheduleID = "ScheduleId" | |||
|
|
|||
| ActivityId = "ActivityId" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, add a TODO to remove this hardcoded constant.
| customSAName := "ActivityCustomKeyword" | ||
| customSAValue := "custom-sa-test-value" | ||
|
|
||
| _, err := s.OperatorClient().AddSearchAttributes(ctx, &operatorservice.AddSearchAttributesRequest{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a set of custom search attributes already defined for all functional tests.
| }) | ||
|
|
||
| t.Run("QueryByActivityStatus", func(t *testing.T) { | ||
| verifyListQuery(t, fmt.Sprintf("ActivityStatus = 'Scheduled' AND ActivityType = '%s'", activityType)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's Scheduled? It's supposed Running as we have for ExecutionStatus for workflows (case sensitive?)
| s.Equal(activityID, exec.GetActivityId()) | ||
| s.Equal(runID, exec.GetRunId()) | ||
| s.Equal(activityType, exec.GetActivityType().GetName()) | ||
| s.Equal(enumspb.ACTIVITY_EXECUTION_STATUS_RUNNING, exec.GetStatus()) | ||
| s.NotNil(exec.GetScheduleTime()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make sure you cover all of the fields of ActivityExecutionListInfo in this test.
| ActivityId: exec.BusinessID, | ||
| RunId: exec.RunID, | ||
| ScheduleTime: timestamppb.New(exec.StartTime), | ||
| CloseTime: timestamppb.New(exec.CloseTime), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: CloseTime incorrectly set to Unix epoch for running activities
CloseTime is unconditionally set using timestamppb.New(exec.CloseTime) for all activities, including running ones. When exec.CloseTime is a zero time.Time (for non-closed activities), timestamppb.New creates a timestamp representing Unix epoch (1970-01-01 00:00:00) instead of nil. The existing workflow visibility code at visibility_manager_impl.go only sets CloseTime when the execution status is not running. The activity list response will incorrectly show all running activities as having a CloseTime of 1970-01-01.
083b015 to
4f365ba
Compare
| func (a *Activity) SearchAttributes(_ chasm.Context) []chasm.SearchAttributeKeyValue { | ||
| return []chasm.SearchAttributeKeyValue{ | ||
| ActivityTypeSearchAttribute.Value(a.GetActivityType().GetName()), | ||
| ActivityStatusSearchAttribute.Value(a.GetStatus().String()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: ActivityStatus stores internal status instead of public API status
The SearchAttributes method stores the internal activity status string (e.g., "Scheduled", "Started") via a.GetStatus().String(), but the reviewer @bergundy noted this should match workflow behavior where ExecutionStatus stores the public API status ("Running"). This creates an inconsistency: users must query ActivityStatus = 'Scheduled' or ActivityStatus = 'Started' to find running activities, whereas for workflows they would query ExecutionStatus = 'Running'. The value stored should likely be InternalStatusToAPIStatus(a.GetStatus()).String() to match the public status shown in list responses.
Implement standalone activity ListActivityExecutions and CountActivityExecutions.
Note
Implements list and count APIs for standalone activities, wiring CHASM visibility, adding search attributes/memo, status mappings, and supporting query aliasing; includes proto additions and comprehensive tests.
ListActivityExecutionsandCountActivityExecutionshandlers usingchasm.ListExecutions/CountExecutionsandVisibilityManagercontext.ActivityExecutionListInfo(incl. duration) and expose grouped counts.VisibilitySearchAttributesProviderandVisibilityMemoProviderwith new SAs:ActivityType,ActivityStatus,ActivityTaskQueue.activitypb.ActivityListMemoand status conversion helpers (InternalStatusToAPIStatus,internalStatusToRunState).ActivityListMemomessage and generated helpers.visibility.NewChasmVisibilityManagerto frontend module; register component with SAs.ActivityIdby mapping toWorkflowIdin visibility queries.Written by Cursor Bugbot for commit 4f365ba. This will update automatically on new commits. Configure here.