Skip to content

Commit e761b05

Browse files
authored
feat(submitqueue): Add queuepause Store contract and QueuePause entity (#862)
## Why? Operators need to pause a queue at runtime without redeploying (see the pause and unpause RFC). The pause state needs its own source, separate from queue config, so each deployment can back it with whatever it uses for runtime config. ## What? - `entity.QueuePause`: two independent switches, `RejectLands` and `FreezeProcessing`. The zero value means not paused. - `queuepause.Store`: a single `Get(ctx, queue)` contract. A queue with no entry returns the zero state, and an error means the backend could not be read, never that the queue is unpaused. - The mock, a README, and the new package added to the mock generation list. ## Test Plan `bazel build //submitqueue/extension/queuepause/... //submitqueue/entity/...` `make lint` `make check-gazelle` `make check-tidy` CI ## Issue
1 parent 1b70f66 commit e761b05

8 files changed

Lines changed: 158 additions & 0 deletions

File tree

‎Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,7 @@ GO_GENERATE_PACKAGES := \
632632
./submitqueue/extension/changeprovider/... \
633633
./submitqueue/extension/conflict/... \
634634
./submitqueue/extension/queueconfig/... \
635+
./submitqueue/extension/queuepause/... \
635636
./submitqueue/extension/speculation/... \
636637
./submitqueue/extension/storage/... \
637638
./submitqueue/extension/validator/... \

‎submitqueue/entity/BUILD.bazel‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ go_library(
1616
"path_build.go",
1717
"queue_batch_state.go",
1818
"queue_config.go",
19+
"queue_pause.go",
1920
"request.go",
2021
"request_batch.go",
2122
"request_history.go",

‎submitqueue/entity/queue_pause.go‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Copyright (c) 2026 Uber Technologies, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package entity
16+
17+
// QueuePause is a point-in-time snapshot of the pause switches of a single
18+
// queue. The two switches are independent, and the zero value means the queue
19+
// is not paused.
20+
type QueuePause struct {
21+
// RejectLands is true while the queue refuses new land requests.
22+
RejectLands bool
23+
24+
// FreezeProcessing is true while the queue's accepted requests are not advanced.
25+
FreezeProcessing bool
26+
27+
// Reason is the operator's free-text explanation for the pause. Empty when none was given.
28+
Reason string
29+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
load("@rules_go//go:def.bzl", "go_library")
2+
3+
go_library(
4+
name = "go_default_library",
5+
srcs = ["queuepause.go"],
6+
importpath = "github.com/uber/submitqueue/submitqueue/extension/queuepause",
7+
visibility = ["//visibility:public"],
8+
deps = ["//submitqueue/entity:go_default_library"],
9+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Queue Pause Extension
2+
3+
Vendor-agnostic source of per-queue pause state. See [the pause and unpause RFC](../../../doc/rfc/submitqueue/queue-pause-and-unpause.md) for the design.
4+
5+
## Interfaces
6+
7+
### Store
8+
9+
Returns the pause state of a queue by name. The state is two independent switches: reject new land requests, and freeze processing of accepted requests. A queue with no entry is not paused, and an error means the backend could not be read.
10+
11+
The store only reports state. The gateway and orchestrator enforce it, so every deployment runs the same rejection and freezing logic and only the source of the state differs.
12+
13+
## Entities
14+
15+
`QueuePause` lives in `submitqueue/entity/queue_pause.go`.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
load("@rules_go//go:def.bzl", "go_library")
2+
3+
go_library(
4+
name = "go_default_library",
5+
srcs = ["queuepause_mock.go"],
6+
importpath = "github.com/uber/submitqueue/submitqueue/extension/queuepause/mock",
7+
visibility = ["//visibility:public"],
8+
deps = [
9+
"//submitqueue/entity:go_default_library",
10+
"@org_uber_go_mock//gomock:go_default_library",
11+
],
12+
)

‎submitqueue/extension/queuepause/mock/queuepause_mock.go‎

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) 2026 Uber Technologies, Inc.
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package queuepause
16+
17+
//go:generate mockgen -source=queuepause.go -destination=mock/queuepause_mock.go -package=mock
18+
19+
import (
20+
"context"
21+
22+
"github.com/uber/submitqueue/submitqueue/entity"
23+
)
24+
25+
// Store is the source of per-queue pause state. It reports the switches and
26+
// decides nothing; enforcement lives in the services that resolve it.
27+
type Store interface {
28+
// Get returns the current pause state of a queue. A queue with no entry
29+
// returns the zero state (not paused) and no error. A non-nil error means
30+
// the backend could not be read, not that the queue is unpaused; a caller
31+
// that enforces a switch must not fail open on it. Implementations must be
32+
// safe for concurrent use.
33+
Get(ctx context.Context, queue string) (entity.QueuePause, error)
34+
}

0 commit comments

Comments
 (0)