Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions stovepipe/entity/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("@rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"broken_project.go",
"build.go",
"build_issue.go",
"get_issues_by_request_id.go",
Expand Down
23 changes: 23 additions & 0 deletions stovepipe/entity/broken_project.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2026 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package entity

// BrokenProject identifies a project's current broken period within a queue.
type BrokenProject struct {
// Project identifies the project within the queue.
Project string
// FirstBrokenRequestID identifies the request that opened this broken period.
FirstBrokenRequestID string
}
1 change: 1 addition & 0 deletions stovepipe/extension/storage/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("@rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"broken_project_store.go",
"build_issue_store.go",
"build_store.go",
"issue_log_store.go",
Expand Down
9 changes: 9 additions & 0 deletions stovepipe/extension/storage/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ Callers own ordering, transitions, and version advancement. The store provides
conditional snapshot writes only; it does not populate summaries or change
immutable validation facts.

## Broken-project lookup

`BrokenProjectStore` retains one opening reference per `(queue, project)`, following
the open-issue lookup pattern. Listing uses bounded bytewise project-key ranges;
a deleted cursor remains valid. Replacement and deletion match the expected
opening request so delayed cleanup cannot remove a newer broken period.
Readers verify membership and opening identity against project summaries.
The store does not maintain the index or change lifecycle state.

## Read-after-write consistency

A `Get` immediately following a successful write (`Create`/`Update`) — by the same caller, or a causally-dependent one such as a queue consumer processing a message published after the write committed — must return that write. This is a requirement on every storage implementation, not a condition callers negotiate around.
Expand Down
53 changes: 53 additions & 0 deletions stovepipe/extension/storage/broken_project_store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) 2026 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package storage

//go:generate mockgen -source=broken_project_store.go -destination=mock/broken_project_store_mock.go -package=mock

import (
"context"

"github.com/uber/submitqueue/stovepipe/entity"
)

// BrokenProjectRange bounds a primary-key scan within the store's queue.
type BrokenProjectRange struct {
// AfterProject excludes this project and earlier keys in bytewise order; empty starts the range.
AfterProject string
// Limit is the positive maximum number of entries to return.
Limit int
}

// BrokenProjectStore retains queue-scoped broken-period references keyed by project.
// Entries are derived lookups; readers must validate them against project summaries.
type BrokenProjectStore interface {
// Create returns ErrAlreadyExists if the project key already exists.
Create(ctx context.Context, entry entity.BrokenProject) error

// Get returns ErrNotFound when the project has no broken-period reference.
Get(ctx context.Context, project string) (entity.BrokenProject, error)

// Replace changes the opening only when it matches expectedFirstBrokenRequestID.
// It returns false for a missing key, a mismatch, or an unchanged opening.
Replace(ctx context.Context, entry entity.BrokenProject, expectedFirstBrokenRequestID string) (bool, error)

// Delete removes the entry only when its opening matches entry.FirstBrokenRequestID.
// It returns false for a missing key or a different opening.
Delete(ctx context.Context, entry entity.BrokenProject) (bool, error)

// List returns at most Limit entries in bytewise project order.
// Membership may change between reads; a cursor need not still exist.
List(ctx context.Context, bounds BrokenProjectRange) ([]entity.BrokenProject, error)
}
1 change: 1 addition & 0 deletions stovepipe/extension/storage/mock/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "go_default_library",
srcs = [
"broken_project_store_mock.go",
"build_issue_store_mock.go",
"build_store_mock.go",
"issue_log_store_mock.go",
Expand Down
117 changes: 117 additions & 0 deletions stovepipe/extension/storage/mock/broken_project_store_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions stovepipe/extension/storage/mock/storage_mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions stovepipe/extension/storage/mysql/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ load("@rules_go//go:def.bzl", "go_library", "go_test")
go_library(
name = "go_default_library",
srcs = [
"broken_project_store.go",
"build_issue_store.go",
"build_store.go",
"issue_log_store.go",
Expand Down Expand Up @@ -42,6 +43,7 @@ go_library(
go_test(
name = "go_default_test",
srcs = [
"broken_project_store_test.go",
"build_issue_list_test.go",
"build_issue_store_test.go",
"build_issue_update_test.go",
Expand Down
Loading