-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add WithContext
functions to executor
#161
Conversation
fe771ec
to
e1c0cca
Compare
WithContext
functions to executorWithContext
functions to executor
- These new `WithContext` functions check the context and pass it to the client instead of just using the root context.
e1c0cca
to
6f17031
Compare
WithContext
functions to executorWithContext
functions to executor
@@ -11,6 +11,5 @@ package rbac | |||
|
|||
type CreateOrUpdateApplicationRequest struct { | |||
// Application's name e.g.: Payment Processors | |||
Name string `json:"name"` | |||
Description string `json"description"` |
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.
there is no description in CreateOrUpdateApplicationRequest
@@ -234,9 +234,7 @@ func contains(haystack []string, needle string) bool { | |||
} | |||
|
|||
func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { | |||
if bodyBuf == nil { |
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.
unnecessary check
@@ -248,7 +246,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e | |||
} else if jsonCheck.MatchString(contentType) { | |||
err = json.NewEncoder(bodyBuf).Encode(body) | |||
} else if xmlCheck.MatchString(contentType) { | |||
xml.NewEncoder(bodyBuf).Encode(body) | |||
err = xml.NewEncoder(bodyBuf).Encode(body) |
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.
missing error handling but I don't think this is being used
if body != nil { | ||
localVarRequest, err = http.NewRequest(method, url.String(), body) | ||
localVarRequest, err = http.NewRequestWithContext(ctx, method, url.String(), body) |
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.
context was propagated but not used at all before these changes
// cancel straightaway on purpose | ||
cancel() | ||
|
||
_, err := executor.StartWorkflowWithContext(ctx, &model.StartWorkflowRequest{}) |
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.
An example test that shows that StartWorkflowWithContext
throws an error if called with a cancelled context.
Changes in this PR
WithContext
functions to executor e.g.:StartWorkflowWithContext
for managing cancellations, timeouts, and deadlines.context.Background()
.HttpRequester
useshttp.NewRequestWithContext
.