-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
f2eca79
batch: add activity reset and update-options
spkane31 6386a98
fixed test for reset
spkane31 2ab3fc2
implement the activity update-options and test it
spkane31 5dffea2
adding the enums for all batch activity options
spkane31 3be16ed
removing logging
spkane31 67b5561
remove extra line
spkane31 cf21122
Merge branch 'main' into spk/batch-reset-update-op
spkane31 4839bf9
pushing to a branch
spkane31 6a231dd
Merge branch 'spk/batch-reset-update-op' of github.com:temporalio/tem…
spkane31 81feb90
go fixup
spkane31 4bb1270
fixing linters
spkane31 92762f4
updating with new protos
spkane31 d15af61
roeys comments
spkane31 0db12cf
Merge branch 'main' into spk/batch-reset-update-op
spkane31 43a6ace
formatting
spkane31 0a0fcfd
Merge branch 'spk/batch-reset-update-op' of github.com:temporalio/tem…
spkane31 f77a9c3
creating structs for ActivityOptions, RetryPolicy, FieldMask to preve…
spkane31 215876c
linting
spkane31 a6cae5d
updating go.mod to master branch
spkane31 9cf8d90
merge conflicts
spkane31 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
package batcher | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
"time" | ||
|
||
|
@@ -11,7 +12,6 @@ import ( | |
"go.temporal.io/sdk/workflow" | ||
"go.temporal.io/server/common/searchattribute" | ||
"go.temporal.io/server/common/worker_versioning" | ||
"google.golang.org/protobuf/types/known/fieldmaskpb" | ||
) | ||
|
||
const ( | ||
|
@@ -42,6 +42,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 ( | ||
|
@@ -92,7 +96,7 @@ type ( | |
// UpdateOptionsParams is the parameters for updating workflow execution options | ||
UpdateOptionsParams struct { | ||
WorkflowExecutionOptions *workflowpb.WorkflowExecutionOptions | ||
UpdateMask *fieldmaskpb.FieldMask | ||
UpdateMask *FieldMask | ||
} | ||
|
||
UnpauseActivitiesParams struct { | ||
|
@@ -103,6 +107,52 @@ type ( | |
Jitter time.Duration | ||
} | ||
|
||
UpdateActivitiesOptionsParams struct { | ||
Identity string | ||
ActivityType string | ||
MatchAll bool | ||
ActivityOptions *ActivityOptions | ||
UpdateMask *FieldMask | ||
RestoreOriginal bool | ||
} | ||
|
||
ActivityOptions struct { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is suboptimal solution. Instead it would have been better to serialize the proto structs manually or to define the workflow inputs with protos. |
||
TaskQueue *TaskQueue | ||
ScheduleToCloseTime time.Duration | ||
ScheduleToStartTimeout time.Duration | ||
StartToCloseTimeout time.Duration | ||
HeartbeatTimeout time.Duration | ||
RetryPolicy *RetryPolicy | ||
} | ||
|
||
TaskQueue struct { | ||
Name string | ||
Kind int32 | ||
} | ||
|
||
RetryPolicy struct { | ||
InitialInterval time.Duration | ||
BackoffCoefficient float64 | ||
MaximumInterval time.Duration | ||
MaximumAttempts int32 | ||
NonRetryableErrorTypes []string | ||
} | ||
|
||
ResetActivitiesParams struct { | ||
Identity string | ||
ActivityType string | ||
MatchAll bool | ||
ResetAttempts bool | ||
ResetHeartbeat bool | ||
KeepPaused bool | ||
Jitter time.Duration | ||
RestoreOriginalOptions bool | ||
} | ||
|
||
FieldMask struct { | ||
Paths []string | ||
} | ||
|
||
// BatchParams is the parameters for batch operation workflow | ||
BatchParams struct { | ||
// Target namespace to execute batch operation | ||
|
@@ -131,6 +181,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 +311,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) | ||
} | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.