-
Notifications
You must be signed in to change notification settings - Fork 25
CRE-1325 #1713
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: main
Are you sure you want to change the base?
CRE-1325 #1713
Changes from all commits
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 | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -75,7 +75,7 @@ func (p *Plugin) Observation(_ context.Context, outctx ocr3types.OutcomeContext, | |||||||||||||||||||||||||||||||||||||||||||||
| if req.ExpiryTime().Before(timeoutCheck) { | ||||||||||||||||||||||||||||||||||||||||||||||
| // Request has been sitting in queue too long | ||||||||||||||||||||||||||||||||||||||||||||||
| p.store.RemoveRequest(req.WorkflowExecutionID) | ||||||||||||||||||||||||||||||||||||||||||||||
| req.SendTimeout(nil) | ||||||||||||||||||||||||||||||||||||||||||||||
| req.SendTimeout(context.Background()) | ||||||||||||||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
@@ -89,14 +89,16 @@ func (p *Plugin) Observation(_ context.Context, outctx ocr3types.OutcomeContext, | |||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| if req.SeqNum > numObservedDonTimes { | ||||||||||||||||||||||||||||||||||||||||||||||
| p.store.RemoveRequest(req.WorkflowExecutionID) | ||||||||||||||||||||||||||||||||||||||||||||||
| req.SendResponse(nil, | ||||||||||||||||||||||||||||||||||||||||||||||
| ctx, cancel := context.WithDeadline(context.Background(), req.ExpiryTime()) | ||||||||||||||||||||||||||||||||||||||||||||||
| req.SendResponse(ctx, | ||||||||||||||||||||||||||||||||||||||||||||||
| Response{ | ||||||||||||||||||||||||||||||||||||||||||||||
| WorkflowExecutionID: req.WorkflowExecutionID, | ||||||||||||||||||||||||||||||||||||||||||||||
| SeqNum: req.SeqNum, | ||||||||||||||||||||||||||||||||||||||||||||||
| Timestamp: 0, | ||||||||||||||||||||||||||||||||||||||||||||||
| Err: fmt.Errorf("requested seqNum %d for executionID %s is greater than the number of observed don times %d", | ||||||||||||||||||||||||||||||||||||||||||||||
| req.SeqNum, req.WorkflowExecutionID, numObservedDonTimes), | ||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||
| cancel() | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+92
to
+101
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. re: @pavel-raykov - you can use anonymous closures to reduce scope of deferred actions:
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
| continue | ||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -25,21 +25,28 @@ func (r *Request) ExpiryTime() time.Time { | |||||||||||||||||||
| return r.ExpiresAt | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| func (r *Request) SendResponse(_ context.Context, resp Response) { | ||||||||||||||||||||
| func (r *Request) SendResponse(ctx context.Context, resp Response) { | ||||||||||||||||||||
| select { | ||||||||||||||||||||
| case r.CallbackCh <- resp: | ||||||||||||||||||||
| close(r.CallbackCh) | ||||||||||||||||||||
| default: // Don't block trying to send | ||||||||||||||||||||
| default: | ||||||||||||||||||||
| // Don't block if receiver not ready, but check if context is actually expired | ||||||||||||||||||||
| select { | ||||||||||||||||||||
| case <-ctx.Done(): | ||||||||||||||||||||
| // Context cancelled or deadline exceeded before send | ||||||||||||||||||||
| default: | ||||||||||||||||||||
| // Try once more without blocking | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+33
to
+39
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. You can just check for an error instead of using the channel mechanism:
Suggested change
But what is meant to happen here? Both cases are no-ops. |
||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| func (r *Request) SendTimeout(_ context.Context) { | ||||||||||||||||||||
| func (r *Request) SendTimeout(ctx context.Context) { | ||||||||||||||||||||
| timeoutResponse := Response{ | ||||||||||||||||||||
| WorkflowExecutionID: r.WorkflowExecutionID, | ||||||||||||||||||||
| SeqNum: r.SeqNum, | ||||||||||||||||||||
| Err: fmt.Errorf("timeout exceeded: could not process request before expiry, workflowExecutionID %s", r.WorkflowExecutionID), | ||||||||||||||||||||
| } | ||||||||||||||||||||
| r.SendResponse(nil, timeoutResponse) | ||||||||||||||||||||
| r.SendResponse(ctx, timeoutResponse) | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| func (r *Request) Copy() *Request { | ||||||||||||||||||||
|
|
||||||||||||||||||||
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 do you want to achieve with this cancel? The SendRepsonse is a sync function that either succeeds or fails. Calling cancel() afterwards does not seem to do anything.