Skip to content

Commit 421a4a4

Browse files
authored
Merge branch 'main' into preetam/queue-tools
2 parents f72c4da + 23e6f5c commit 421a4a4

6 files changed

Lines changed: 118 additions & 1 deletion

File tree

entity/BUILD.bazel

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ go_library(
77
"batch_dependent.go",
88
"build.go",
99
"change_provider.go",
10+
"queue_config.go",
1011
"request.go",
1112
"speculation_tree.go",
1213
],
@@ -16,7 +17,10 @@ go_library(
1617

1718
go_test(
1819
name = "entity_test",
19-
srcs = ["request_test.go"],
20+
srcs = [
21+
"queue_config_test.go",
22+
"request_test.go",
23+
],
2024
embed = [":entity"],
2125
deps = [
2226
"@com_github_stretchr_testify//assert",

entity/queue_config.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package entity
2+
3+
// QueueConfig holds the configuration for a single submit queue.
4+
// Each queue maps a VCS repository + target to a processing pipeline.
5+
// A repository can have multiple queues, but each queue has exactly one target.
6+
// Immutable after creation.
7+
type QueueConfig struct {
8+
// Name uniquely identifies this queue within the system.
9+
// Referenced by Request.Queue.
10+
Name string
11+
12+
// VCSType identifies the version control system (e.g., "git", "svn", "perforce").
13+
// A queue operates on exactly one VCS.
14+
VCSType string
15+
16+
// VCSAddress identifies the repository in the version control system.
17+
// The format is VCS-specific:
18+
// - Git: remote URL (e.g., "git@github.com:uber/submitqueue.git")
19+
// - Perforce: depot path (e.g., "//depot/project")
20+
// - SVN: repository URL (e.g., "https://svn.example.com/repos/project")
21+
VCSAddress string
22+
23+
// Target is the landing target where changes are merged.
24+
// The format is VCS-specific:
25+
// - Git: branch ref (e.g., "main", "release/v2")
26+
// - Perforce: stream or depot path (e.g., "//depot/main/...")
27+
// - SVN: repository path (e.g., "trunk/")
28+
Target string
29+
}
30+
31+
// NewQueueConfig creates a new QueueConfig with the given parameters.
32+
func NewQueueConfig(
33+
name string,
34+
vcsType string,
35+
vcsAddress string,
36+
target string,
37+
) QueueConfig {
38+
return QueueConfig{
39+
Name: name,
40+
VCSType: vcsType,
41+
VCSAddress: vcsAddress,
42+
Target: target,
43+
}
44+
}

entity/queue_config_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package entity
2+
3+
import (
4+
"testing"
5+
6+
"github.com/stretchr/testify/assert"
7+
)
8+
9+
func TestNewQueueConfig(t *testing.T) {
10+
cfg := NewQueueConfig("uber/submitqueue/main", "git", "git@github.com:uber/submitqueue.git", "main")
11+
12+
assert.Equal(t, "uber/submitqueue/main", cfg.Name)
13+
assert.Equal(t, "git", cfg.VCSType)
14+
assert.Equal(t, "git@github.com:uber/submitqueue.git", cfg.VCSAddress)
15+
assert.Equal(t, "main", cfg.Target)
16+
}

extension/queueconfig/BUILD.bazel

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 = "queueconfig",
5+
srcs = ["queueconfig.go"],
6+
importpath = "github.com/uber/submitqueue/extension/queueconfig",
7+
visibility = ["//visibility:public"],
8+
deps = ["//entity"],
9+
)

extension/queueconfig/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Queue Config Extension
2+
3+
Vendor-agnostic interface for providing queue configurations.
4+
5+
## Interfaces
6+
7+
### Store
8+
9+
Provides queue configurations by name.
10+
11+
```go
12+
type Store interface {
13+
Get(ctx context.Context, name string) (entity.QueueConfig, error)
14+
List(ctx context.Context) ([]entity.QueueConfig, error)
15+
}
16+
```
17+
18+
## Entities
19+
20+
Queue configuration entity lives in `entity/queue_config.go`:
21+
22+
- **QueueConfig** — configuration for a single submit queue (name, VCS type, VCS repo, target)
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package queueconfig
2+
3+
import (
4+
"context"
5+
"errors"
6+
7+
"github.com/uber/submitqueue/entity"
8+
)
9+
10+
// ErrNotFound is returned when the requested queue configuration does not exist.
11+
var ErrNotFound = errors.New("queue config not found")
12+
13+
// Store loads and provides queue configurations.
14+
// Implementations may read from YAML files, databases, remote services, etc.
15+
type Store interface {
16+
// Get returns the configuration for a named queue.
17+
// Returns ErrNotFound if no configuration exists for the given name.
18+
Get(ctx context.Context, name string) (entity.QueueConfig, error)
19+
20+
// List returns all configured queues.
21+
List(ctx context.Context) ([]entity.QueueConfig, error)
22+
}

0 commit comments

Comments
 (0)