-
Notifications
You must be signed in to change notification settings - Fork 35
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 /tasks patch; return 202 for task actions and updates. #660
Conversation
Signed-off-by: Jeff Ortel <jortel@redhat.com>
Signed-off-by: Jeff Ortel <jortel@redhat.com>
const ( | ||
LocatorParam = "locator" | ||
) | ||
|
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.
hint: LocatorParam unused. The /tasks now supports filtering.
api/task.go
Outdated
@@ -55,10 +51,11 @@ func (h TaskHandler) AddRoutes(e *gin.Engine) { | |||
routeGroup.POST(TasksRoot, h.Create) | |||
routeGroup.GET(TaskRoot, h.Get) | |||
routeGroup.PUT(TaskRoot, h.Update) | |||
routeGroup.PATCH(TaskRoot, Transaction, h.Patch) |
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.
hint: add patch.
routeGroup.DELETE(TaskRoot, h.Delete) | ||
routeGroup.GET(TasksReportQueueRoot, h.Queued) | ||
// Actions | ||
routeGroup.PUT(TaskSubmitRoot, h.Submit, h.Update) | ||
routeGroup.PUT(TaskSubmitRoot, Transaction, h.Submit) |
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.
hint: with complexity delegated to the task manager, simpler to implement submit as a patch and no longer chain submit; state=Ready; update().
BaseHandler.modBody() should probably go away.
Signed-off-by: Jeff Ortel <jortel@redhat.com>
} | ||
|
||
// Submit godoc | ||
// @summary Submit a task. | ||
// @description Submit a task. | ||
// @description Patch and submit a task. |
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.
hint: Much better for the caller to be able to patch a task when submitting rather than update. This will support submit with minimal or no patch.
Signed-off-by: Jeff Ortel <jortel@redhat.com>
Signed-off-by: Jeff Ortel <jortel@redhat.com>
Signed-off-by: Jeff Ortel <jortel@redhat.com>
Signed-off-by: Jeff Ortel <jortel@redhat.com>
ctx.Request.Body = io.NopCloser(bfr) | ||
return | ||
} | ||
|
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.
hint: removed in favor of simpler, more direct approach.
Signed-off-by: Jeff Ortel <jortel@redhat.com>
task/manager.go
Outdated
@@ -188,23 +188,19 @@ func (m *Manager) Update(db *gorm.DB, requested *Task) (err error) { | |||
task.TTL = requested.TTL | |||
task.Data = requested.Data | |||
task.ApplicationID = requested.ApplicationID | |||
task.BucketID = requested.BucketID |
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.
hint: fixes taskgroup bucket propagation broken in multi-provider pr.
Signed-off-by: Jeff Ortel <jortel@redhat.com>
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.
LGTM
@@ -150,6 +150,7 @@ func (m *Manager) Create(db *gorm.DB, requested *Task) (err error) { | |||
task.TTL = requested.TTL | |||
task.Data = requested.Data | |||
task.ApplicationID = requested.ApplicationID | |||
task.BucketID = requested.BucketID |
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.
hint: fixes task group bucket propagation. ^ broken by earlier multi-provider PR.
noticed while regression testing.
Signed-off-by: Jeff Ortel <jortel@redhat.com>
Adds patch endpoints for:
The Update() methods on both Task and Taskgroup support both PUT and PATCH depending on the http method. They also support delegation from Submit() which mainly sets the state=Ready.
Updated to return 202 (accepted) on success.
BaseHandler.modBody() removed.
Add patch support to binding client.
Adds API test for task patch.
closes: #661
closes: #662