Skip to content

Commit 883bf2f

Browse files
committed
fix(gateway): align list sort and window semantics
1 parent 1b94b24 commit 883bf2f

6 files changed

Lines changed: 86 additions & 88 deletions

File tree

submitqueue/extension/storage/mysql/request_summary_store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ func (s *requestSummaryStore) List(ctx context.Context, opts storage.RequestSumm
133133
clauses := []string{
134134
"queue = ?",
135135
"started_at_ms < ?",
136-
"completed_at_ms >= ?",
136+
"completed_at_ms > ?",
137137
}
138138

139139
if len(opts.Statuses) > 0 {

submitqueue/gateway/controller/list.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,9 @@ func canonicalStatuses(raw []string) ([]entity.RequestStatus, error) {
217217

218218
func requestSummarySort(sort pb.ListSort) (storage.RequestSummarySort, error) {
219219
switch sort {
220-
case pb.ListSort_LIST_SORTED_UNSPECIFIED, pb.ListSort_LIST_SORTED_ADMITTED_ASC:
220+
case pb.ListSort_SORT_DEFAULT, pb.ListSort_ADMITTED_ASC:
221221
return storage.RequestSummarySortAdmittedAsc, nil
222-
case pb.ListSort_LIST_SORTED_ADMITTED_DESC:
222+
case pb.ListSort_ADMITTED_DESC:
223223
return storage.RequestSummarySortAdmittedDesc, nil
224224
default:
225225
return "", fmt.Errorf("unknown sort %v: %w", sort, ErrInvalidRequest)

submitqueue/gateway/controller/list_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestList_UsesRequestedSort(t *testing.T) {
108108
Queue: "q",
109109
StartTimeMs: 100,
110110
EndTimeMs: 200,
111-
Sort: pb.ListSort_LIST_SORTED_ADMITTED_DESC,
111+
Sort: pb.ListSort_ADMITTED_DESC,
112112
})
113113

114114
require.NoError(t, err)
@@ -278,7 +278,7 @@ func TestList_RejectsMismatchedPageTokenSort(t *testing.T) {
278278
Queue: "q",
279279
StartTimeMs: 1,
280280
EndTimeMs: 2,
281-
Sort: pb.ListSort_LIST_SORTED_ADMITTED_ASC,
281+
Sort: pb.ListSort_ADMITTED_ASC,
282282
PageToken: token,
283283
})
284284

submitqueue/gateway/proto/gateway.proto

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,12 @@ message StatusResponse {
128128

129129
// ListSort defines supported deterministic orderings for List.
130130
enum ListSort {
131-
// Server default: LIST_SORTED_ADMITTED_ASC.
132-
LIST_SORTED_UNSPECIFIED = 0;
131+
// Server default: ADMITTED_ASC.
132+
SORT_DEFAULT = 0;
133133
// FIFO/admission order.
134-
LIST_SORTED_ADMITTED_ASC = 1;
134+
ADMITTED_ASC = 1;
135135
// Newest admissions first.
136-
LIST_SORTED_ADMITTED_DESC = 2;
136+
ADMITTED_DESC = 2;
137137
}
138138

139139
// ListRequest defines a request to list queue requests whose lifecycles overlap a time window.

submitqueue/gateway/protopb/gateway.pb.go

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

submitqueue/gateway/protopb/gateway.pb.yarpc.go

Lines changed: 61 additions & 63 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)