-
Notifications
You must be signed in to change notification settings - Fork 41
feat(worfklows): Allow server side pagination and filtering for workflows #1512
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
Conversation
8d8b3a2 to
c2b39db
Compare
e116e91 to
ffea251
Compare
…lows Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
ffea251 to
805079f
Compare
migmartri
left a comment
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.
Great, my main concern is about compatibility support in the API and if we have removed any functionality there i.e filter by projectID
| } | ||
|
|
||
| // OffsetPaginationResponse is used to return the pagination information | ||
| message OffsetPaginationResponse { |
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.
out of curiosity, is this a common response type for this kind of pagination?
last_page could be calculated by total_count / page_size >= page?
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.
Depending on where you search there is a different response. It seems the most common pattern is:
- page: current page
- page_size: the number of results per page
- total_count: total number of results
I've additionally added the last_page so clients don't need to that exact calculation that you're doing. Instead, another common element is to return the amount of pages. I will remove the last_page and add a total_pages.
| // The (zero-based) offset of the first item returned in the collection. | ||
| int32 page = 1 [(buf.validate.field).int32.gte = 1]; | ||
| // The maximum number of entries to return. If the value exceeds the maximum, then the maximum value will be used. | ||
| int32 page_size = 2 [(buf.validate.field).int32.gt = 0, (buf.validate.field).int32.lte = 100]; |
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.
is it mandatory? why don't we have a default?
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.
The message itself is not required, only if you provide it. The only default values are in the biz layer. I can add the default values here.
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.
I have been searching and I couldn't find a way to specify a default value on proto3, apparently it was an option of proto2. I have found this resource https://stackoverflow.com/questions/33222551/why-are-there-no-custom-default-values-in-proto3
In any case, rest assure there are default values if the pagination is not provided a default pagination object is created:
// Initialize the pagination options, with default values
paginationOpts := pagination.NewDefaultOffsetPaginationOpts()
// Override the pagination options if they are provided
if req.GetPagination() != nil {
paginationOpts, err = pagination.NewOffsetPaginationOpts(
int(req.GetPagination().GetPage()),
int(req.GetPagination().GetPageSize()),
)
if err != nil {
return nil, handleUseCaseErr(err, s.log)
}
}| message WorkflowServiceDeleteResponse {} | ||
|
|
||
| message WorkflowServiceListRequest { | ||
| optional EntityRef project_reference = 1; |
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.
this will break compatibility, are we ok with it?
EntityRef allowed us to also find by projectID?
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.
Yes, we are breaking compatibility but I have search everywhere and we are not using the field anywhere, so my take is that it's safe to be removed.
Yes, EntityRef allowed us to find by projectID, instead now, you can pass repeated number of project names.
| // The team the workflow belongs to | ||
| string workflow_team = 2 [(buf.validate.field).ignore_empty = true]; | ||
| // The project the workflow belongs to | ||
| repeated string project_names = 3 [(buf.validate.field).ignore_empty = true]; |
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.
[(buf.validate.field).ignore_empty = true] not necessary is it?
| // The name of the workflow to filter by | ||
| string workflow_name = 1 [(buf.validate.field).ignore_empty = true]; | ||
| // The team the workflow belongs to | ||
| string workflow_team = 2 [(buf.validate.field).ignore_empty = true]; |
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.
useless validation? [(buf.validate.field).ignore_empty = true];
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.
Hmm I will check this one and the next one.
Signed-off-by: Javier Rodriguez <javier@chainloop.dev>
…or workflows (chainloop-dev#1512)" This reverts commit 2c8a4ff.
|
Thanks @javirln for getting back to my questions. LGTM! |
This pull request introduces offset-based pagination to the control plane API, alongside other enhancements. The most important changes include the addition of new pagination request and response types, updates to the workflow service to support filtering and pagination.
Pagination Enhancements:
OffsetPaginationRequestandOffsetPaginationResponsetypes to handle offset-based pagination.pagination.prototo include definitions forOffsetPaginationRequestandOffsetPaginationResponse.Workflow Service Enhancements:
WorkflowServiceListRequestto support additional filtering options and includedOffsetPaginationRequestfor pagination.OffsetPaginationResponsetoWorkflowServiceListResponseto return pagination information.WorkflowActivityWindowenum to represent the time window for the last known workflow activity.Possible filters:
Other changes
Removes the parameter
project_referencefromWorkflowServiceListRequestsince it was not used anywhere.Default behavior
This changes ensures backwards compatibility by making the pagination options, optional and if not provided only returning a specific number of workflows instead. It's advised to update to most recent version of Chainloop once released to leverage the pagination feature.
Ref: #1503