Skip to content
Open
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 service/submitqueue/orchestrator/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ go_library(
"//platform/extension/consumergate/noop:go_default_library",
"//platform/extension/counter:go_default_library",
"//platform/extension/counter/mysql:go_default_library",
"//platform/extension/hook/noop:go_default_library",
"//platform/extension/messagequeue/mysql:go_default_library",
"//platform/githubactions:go_default_library",
"//platform/http:go_default_library",
Expand Down
2 changes: 2 additions & 0 deletions service/submitqueue/orchestrator/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
consumergatenoop "github.com/uber/submitqueue/platform/extension/consumergate/noop"
"github.com/uber/submitqueue/platform/extension/counter"
mysqlcounter "github.com/uber/submitqueue/platform/extension/counter/mysql"
hooknoop "github.com/uber/submitqueue/platform/extension/hook/noop"
queueMySQL "github.com/uber/submitqueue/platform/extension/messagequeue/mysql"
"github.com/uber/submitqueue/platform/pipeline"
"github.com/uber/submitqueue/submitqueue/core/changeset"
Expand Down Expand Up @@ -198,6 +199,7 @@ func run() error {
Analyzer: profiles.AnalyzerFactory(),
Speculator: profiles.SpeculatorFactory(),
Validator: validatorFactory{},
Hook: hooknoop.New(),
}

// Assemble the pipeline: one call builds the topic registry, creates
Expand Down
20 changes: 19 additions & 1 deletion submitqueue/orchestrator/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
load("@rules_go//go:def.bzl", "go_library")
load("@rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "go_default_library",
srcs = ["pipeline.go"],
importpath = "github.com/uber/submitqueue/submitqueue/orchestrator",
visibility = ["//visibility:public"],
deps = [
"//api/base/hook:go_default_library",
"//api/runway/messagequeue:go_default_library",
"//platform/consumer:go_default_library",
"//platform/extension/counter:go_default_library",
"//platform/extension/hook:go_default_library",
"//platform/hook:go_default_library",
"//platform/pipeline:go_default_library",
"//submitqueue/core/topickey:go_default_library",
"//submitqueue/extension/buildrunner:go_default_library",
Expand All @@ -34,3 +37,18 @@ go_library(
"@org_uber_go_zap//:go_default_library",
],
)

go_test(
name = "go_default_test",
srcs = ["pipeline_test.go"],
embed = [":go_default_library"],
deps = [
"//api/base/hook:go_default_library",
"//platform/extension/hook/noop:go_default_library",
"//platform/pipeline:go_default_library",
"@com_github_stretchr_testify//assert:go_default_library",
"@com_github_stretchr_testify//require:go_default_library",
"@com_github_uber_go_tally//:go_default_library",
"@org_uber_go_zap//zaptest:go_default_library",
],
)
25 changes: 25 additions & 0 deletions submitqueue/orchestrator/pipeline.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,15 @@
package orchestrator

import (
"fmt"

"github.com/uber-go/tally"
basehook "github.com/uber/submitqueue/api/base/hook"
runwaymq "github.com/uber/submitqueue/api/runway/messagequeue"
"github.com/uber/submitqueue/platform/consumer"
"github.com/uber/submitqueue/platform/extension/counter"
hookext "github.com/uber/submitqueue/platform/extension/hook"
platformhook "github.com/uber/submitqueue/platform/hook"
"github.com/uber/submitqueue/platform/pipeline"
"github.com/uber/submitqueue/submitqueue/core/topickey"
"github.com/uber/submitqueue/submitqueue/extension/buildrunner"
Expand Down Expand Up @@ -77,6 +82,10 @@ type Deps struct {

// Validator resolves the validator for each queue.
Validator validator.Factory

// Hook receives lifecycle events for fire-and-forget side effects. Wire
// noop when the deployment has no integrations.
Hook hookext.Hook
}

// Stages is the orchestrator's pipeline topology as a typed table.
Expand Down Expand Up @@ -211,6 +220,22 @@ var Stages = []pipeline.Stage[Deps]{
return dlq.NewDLQBatchController(d.Logger, d.Scope, d.Storage, sc.Registry, sc.TopicKey, sc.ConsumerGroup), nil
},
},
// Any stage can publish here and this one publishes nothing onward, so the
// row sits outside the flow the rest of the table is ordered by.
{
Key: basehook.TopicKeyHook,
Name: "submitqueue-hook",
ConsumerGroup: "orchestrator",
New: func(d Deps, sc pipeline.StageContext) (consumer.Controller, error) {
if d.Hook == nil {
return nil, fmt.Errorf("hook is required; wire noop when the deployment has no integrations")
}
return platformhook.NewDispatcher(d.Logger, d.Scope, d.Hook, sc.TopicKey, sc.ConsumerGroup), nil
},
DLQ: func(d Deps, sc pipeline.StageContext) (consumer.Controller, error) {
return platformhook.NewDLQController(d.Logger, d.Scope, sc.TopicKey, sc.ConsumerGroup), nil
},
},
}

// PublishOnlyTopics declares topics the orchestrator publishes to but does
Expand Down
73 changes: 73 additions & 0 deletions submitqueue/orchestrator/pipeline_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// 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 orchestrator

import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/uber-go/tally"
basehook "github.com/uber/submitqueue/api/base/hook"
hooknoop "github.com/uber/submitqueue/platform/extension/hook/noop"
"github.com/uber/submitqueue/platform/pipeline"
"go.uber.org/zap/zaptest"
)

func hookStage(t *testing.T) pipeline.Stage[Deps] {
t.Helper()
for _, s := range Stages {
if s.Key == basehook.TopicKeyHook {
return s
}
}
require.FailNow(t, "no stage is registered for the hook topic key")
return pipeline.Stage[Deps]{}
}

func TestHookStage(t *testing.T) {
deps := func(t *testing.T) Deps {
return Deps{
Logger: zaptest.NewLogger(t).Sugar(),
Scope: tally.NoopScope,
Hook: hooknoop.New(),
}
}
stageContext := func(key string) pipeline.StageContext {
return pipeline.StageContext{
TopicKey: basehook.TopicKey(key),
ConsumerGroup: "orchestrator",
}
}

t.Run("dispatcher subscribes to the key the engine assigns", func(t *testing.T) {
controller, err := hookStage(t).New(deps(t), stageContext("hook"))
require.NoError(t, err)
assert.Equal(t, basehook.TopicKeyHook, controller.TopicKey())
})

t.Run("reconciler subscribes to the dead-letter key the engine derives", func(t *testing.T) {
controller, err := hookStage(t).DLQ(deps(t), stageContext("hook_dlq"))
require.NoError(t, err)
assert.Equal(t, basehook.TopicKey("hook_dlq"), controller.TopicKey())
})

t.Run("a host that leaves the hook unwired fails to construct", func(t *testing.T) {
d := deps(t)
d.Hook = nil
_, err := hookStage(t).New(d, stageContext("hook"))
require.Error(t, err)
})
}
Loading