-
Notifications
You must be signed in to change notification settings - Fork 1.2k
batch: add activity reset and update-options #8061
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
Changes from 16 commits
f2eca79
6386a98
2ab3fc2
5dffea2
3be16ed
67b5561
cf21122
4839bf9
6a231dd
81feb90
4bb1270
92762f4
d15af61
0db12cf
43a6ace
0a0fcfd
f77a9c3
215876c
a6cae5d
9cf8d90
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,11 @@ | ||
| package batcher | ||
|
|
||
| import ( | ||
| "errors" | ||
| "fmt" | ||
| "time" | ||
|
|
||
| activitypb "go.temporal.io/api/activity/v1" | ||
| commonpb "go.temporal.io/api/common/v1" | ||
| enumspb "go.temporal.io/api/enums/v1" | ||
| workflowpb "go.temporal.io/api/workflow/v1" | ||
|
|
@@ -42,6 +44,10 @@ const ( | |
| BatchTypeUpdateOptions = "update_options" | ||
| // BatchTypePauseActivities is batch type for unpausing activities | ||
| BatchTypeUnpauseActivities = "unpause_activities" | ||
| // BatchTypeUpdateActivitiesOptions is batch type for updating the options of activities | ||
| BatchTypeUpdateActivitiesOptions = "update_activity_options" | ||
| // BatchTypeResetActivities is batch type for resetting activities | ||
| BatchTypeResetActivities = "reset_activities" | ||
| ) | ||
|
|
||
| var ( | ||
|
|
@@ -103,6 +109,26 @@ type ( | |
| Jitter time.Duration | ||
| } | ||
|
|
||
| UpdateActivitiesOptionsParams struct { | ||
| Identity string | ||
| ActivityType string | ||
| MatchAll bool | ||
| ActivityOptions *activitypb.ActivityOptions | ||
| UpdateMask *fieldmaskpb.FieldMask | ||
|
||
| RestoreOriginal bool | ||
| } | ||
|
|
||
| ResetActivitiesParams struct { | ||
| Identity string | ||
| ActivityType string | ||
| MatchAll bool | ||
| ResetAttempts bool | ||
| ResetHeartbeat bool | ||
| KeepPaused bool | ||
| Jitter time.Duration | ||
| RestoreOriginalOptions bool | ||
| } | ||
|
|
||
| // BatchParams is the parameters for batch operation workflow | ||
| BatchParams struct { | ||
| // Target namespace to execute batch operation | ||
|
|
@@ -131,6 +157,10 @@ type ( | |
| UpdateOptionsParams UpdateOptionsParams | ||
| // UnpauseActivitiesParams is params only for BatchTypeUnpauseActivities | ||
| UnpauseActivitiesParams UnpauseActivitiesParams | ||
| // UpdateActivitiesOptionsParams is params only for BatchTypeUpdateActivitiesOptions | ||
| UpdateActivitiesOptionsParams UpdateActivitiesOptionsParams | ||
| // ResetActivitiesParams is params only for BatchTypeResetActivities | ||
| ResetActivitiesParams ResetActivitiesParams | ||
|
|
||
| // RPS sets the requests-per-second limit for the batch. | ||
| // The default (and max) is defined by `worker.BatcherRPS` in the dynamic config. | ||
|
|
@@ -257,6 +287,16 @@ func validateParams(params BatchParams) error { | |
| return fmt.Errorf("must provide ActivityType or MatchAll") | ||
| } | ||
| return nil | ||
| case BatchTypeResetActivities: | ||
| if params.ResetActivitiesParams.ActivityType == "" && !params.ResetActivitiesParams.MatchAll { | ||
| return errors.New("must provide ActivityType or MatchAll") | ||
| } | ||
| return nil | ||
| case BatchTypeUpdateActivitiesOptions: | ||
| if params.UpdateActivitiesOptionsParams.ActivityType == "" && !params.UpdateActivitiesOptionsParams.MatchAll { | ||
| return errors.New("must provide ActivityType or MatchAll") | ||
| } | ||
| return nil | ||
| default: | ||
| return fmt.Errorf("not supported batch type: %v", params.BatchType) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.