-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Standalone Activity refactor for consistency with Standalone Nexus Operations #9795
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 all commits
7d0c768
ae6fa7b
afb0fa5
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 |
|---|---|---|
|
|
@@ -120,7 +120,7 @@ func validateAndNormalizeActivityAttributes( | |
| return serviceerror.NewInvalidArgumentf("invalid priorities: %v", err) | ||
| } | ||
|
|
||
| return normalizeAndValidateTimeouts(activityID, | ||
| return validateAndNormalizeTimeouts(activityID, | ||
| activityType, | ||
| runTimeout, | ||
| options) | ||
|
|
@@ -140,7 +140,7 @@ func validateActivityRetryPolicy( | |
| return retrypolicy.Validate(retryPolicy) | ||
| } | ||
|
|
||
| func normalizeAndValidateTimeouts( | ||
| func validateAndNormalizeTimeouts( | ||
| activityID string, | ||
| activityType string, | ||
| runTimeout *durationpb.Duration, | ||
|
|
@@ -208,7 +208,7 @@ func normalizeAndValidateTimeouts( | |
| return nil | ||
| } | ||
|
|
||
| func normalizeAndValidateIDPolicy(req *workflowservice.StartActivityExecutionRequest) error { | ||
| func validateAndNormalizeIDPolicy(req *workflowservice.StartActivityExecutionRequest) error { | ||
| if req.GetIdReusePolicy() == enumspb.ACTIVITY_ID_REUSE_POLICY_UNSPECIFIED { | ||
| req.IdReusePolicy = enumspb.ACTIVITY_ID_REUSE_POLICY_ALLOW_DUPLICATE | ||
| } | ||
|
|
@@ -317,7 +317,55 @@ func validatePollActivityExecutionRequest( | |
| return nil | ||
| } | ||
|
|
||
| func validateRequestCancelActivityExecutionRequest( | ||
| func validateAndNormalizeStartRequest( | ||
| req *workflowservice.StartActivityExecutionRequest, | ||
| maxIDLengthLimit int, | ||
| blobSizeLimitError dynamicconfig.IntPropertyFnWithNamespaceFilter, | ||
| blobSizeLimitWarn dynamicconfig.IntPropertyFnWithNamespaceFilter, | ||
| logger log.Logger, | ||
| saMapperProvider searchattribute.MapperProvider, | ||
| saValidator *searchattribute.Validator, | ||
| ) error { | ||
| if req.GetRequestId() == "" { | ||
| req.RequestId = uuid.NewString() | ||
|
Contributor
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 can never happen because
Contributor
Author
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. Good spot. It's true, and this is questionable, but it bothered me to have the cancel and terminate ones doing it and the start one not doing it. That would mean the start one "knows" about what's going on in its upstream caller. So I decided to pay one instruction (or whatever) here and get consistency and future-proofing in return. But lmk if you don't like it. |
||
| } else if len(req.GetRequestId()) > maxIDLengthLimit { | ||
| return serviceerror.NewInvalidArgumentf("request ID exceeds length limit. Length=%d Limit=%d", | ||
| len(req.GetRequestId()), maxIDLengthLimit) | ||
| } | ||
|
|
||
| if len(req.GetIdentity()) > maxIDLengthLimit { | ||
| return serviceerror.NewInvalidArgumentf("identity exceeds length limit. Length=%d Limit=%d", | ||
| len(req.GetIdentity()), maxIDLengthLimit) | ||
| } | ||
|
|
||
| if err := validateAndNormalizeIDPolicy(req); err != nil { | ||
| return err | ||
| } | ||
|
|
||
| if err := validateBlobSize( | ||
| req.GetActivityId(), | ||
| "StartActivityExecution", | ||
| blobSizeLimitError, | ||
| blobSizeLimitWarn, | ||
| req.Input.Size(), | ||
| logger, | ||
| req.GetNamespace()); err != nil { | ||
| return serviceerror.NewInvalidArgument("input exceeds length limit") | ||
| } | ||
|
|
||
| if req.GetSearchAttributes() != nil { | ||
| if err := validateAndNormalizeSearchAttributes( | ||
| req, | ||
| saMapperProvider, | ||
| saValidator); err != nil { | ||
| return err | ||
| } | ||
| } | ||
|
|
||
| return nil | ||
| } | ||
|
|
||
| func validateAndNormalizeCancelRequest( | ||
| req *workflowservice.RequestCancelActivityExecutionRequest, | ||
| maxIDLengthLimit int, | ||
| blobSizeLimitError dynamicconfig.IntPropertyFnWithNamespaceFilter, | ||
|
|
@@ -333,7 +381,9 @@ func validateRequestCancelActivityExecutionRequest( | |
| len(req.GetActivityId()), maxIDLengthLimit) | ||
| } | ||
|
|
||
| if len(req.GetRequestId()) > maxIDLengthLimit { | ||
| if req.GetRequestId() == "" { | ||
| req.RequestId = uuid.NewString() | ||
| } else if len(req.GetRequestId()) > maxIDLengthLimit { | ||
| return serviceerror.NewInvalidArgumentf("request ID exceeds length limit. Length=%d Limit=%d", | ||
| len(req.GetRequestId()), maxIDLengthLimit) | ||
| } | ||
|
|
@@ -365,7 +415,7 @@ func validateRequestCancelActivityExecutionRequest( | |
| return nil | ||
| } | ||
|
|
||
| func validateDeleteActivityExecutionRequest( | ||
| func validateAndNormalizeDeleteRequest( | ||
| req *workflowservice.DeleteActivityExecutionRequest, | ||
| maxIDLengthLimit int, | ||
| ) error { | ||
|
|
@@ -388,7 +438,7 @@ func validateDeleteActivityExecutionRequest( | |
| return nil | ||
| } | ||
|
|
||
| func validateTerminateActivityExecutionRequest( | ||
| func validateAndNormalizeTerminateRequest( | ||
| req *workflowservice.TerminateActivityExecutionRequest, | ||
| maxIDLengthLimit int, | ||
| blobSizeLimitError dynamicconfig.IntPropertyFnWithNamespaceFilter, | ||
|
|
@@ -404,7 +454,9 @@ func validateTerminateActivityExecutionRequest( | |
| len(req.GetActivityId()), maxIDLengthLimit) | ||
| } | ||
|
|
||
| if len(req.GetRequestId()) > maxIDLengthLimit { | ||
| if req.GetRequestId() == "" { | ||
| req.RequestId = uuid.NewString() | ||
| } else if len(req.GetRequestId()) > maxIDLengthLimit { | ||
| return serviceerror.NewInvalidArgumentf("request ID exceeds length limit. Length=%d Limit=%d", | ||
| len(req.GetRequestId()), maxIDLengthLimit) | ||
| } | ||
|
|
||
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.
optional: if you wanted to be clever and remove some duplication you could have this use an interface that only provides
GetRequestId; then you can pass bothStartActivityExecutionRequestandTerminateActivityExecutionRequestinto it