demo

package
v0.3.0-20261014150612-... Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2026 License: Apache-2.0 Imports: 14 Imported by: 0

README

Demo workload runner

This package is the reusable part of the SubmitQueue demo. The OSS command in the sibling requests package and internal commands import github.com/uber/submitqueue/service/submitqueue/demo; deployment configuration, authentication, source construction, and connection ownership remain with those commands.

Run generates changes through a supplied source. RunExisting takes revisions already resolved by the caller and never invokes the source. Both return known changes, accepted request identifiers, and the last observed request histories, including on partial failure. A request identifier is opaque and must always be used with its queue.

Independent changes are created and submitted with bounded concurrency. Each can enter the queue as soon as it is ready. Burst mode prepares every change before submitting any request. Stacked mode creates a chain sequentially, prepares its members, and submits their ordered URIs as one request.

Sources own their base branch or snapshot. A stack link receives the preceding change's branch and head; a source must honor that parent or fail rather than silently retargeting it. The OSS providers retain their frozen-base behavior. A remote source that resolves a branch at creation time can use a moving base without promising identical commit ancestry across independent changes.

Readiness is optional and only runs when submission is enabled. A command can wait for real approvals or checks without baking that policy into the workload generator. Existing-change stack validation is the caller's responsibility.

The runner owns polling and interactive terminal cleanup. It waits for recorded histories rather than sampling only current status, preserving fast transitions and build metadata. Monitoring failures are not request failures: permanent errors stop the local watch without cancelling creation or submission and without inventing a terminal server state, and temporary failures retain the last known status and history.

Mutating source and submission calls are never retried automatically. A failing sibling stops new work from starting and cancels readiness waits, but never cancels a source or submission call already in flight. A timeout may hide a successful remote operation; inspect the reported artifacts before retrying. Stopping the command does not cancel submitted work, close PRs, or delete branches.

Workload layout is deterministic for a supplied RunID; an empty identifier receives a timestamp and random suffix so simultaneous runs do not collide. File/folder controls and the existing OSS command flags and Make targets are unchanged.

Documentation

Overview

Package demo generates and submits workloads with injected change sources and gateway transports. Deployment configuration and credentials belong to the calling command.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Change

type Change struct {
	// Branch is the source branch.
	Branch string
	// HeadSHA is the full revision identifier, empty for an unconfirmed artifact.
	HeadSHA string
	// URI is the head-pinned identifier, empty for an unconfirmed artifact.
	URI string
	// Label identifies the change in terminal output.
	Label string
	// URL is an optional browser link.
	URL string
}

Change is a head-pinned revision, or an attempted branch returned on failure.

type ChangeSpec

type ChangeSpec struct {
	// Branch is the branch to create.
	Branch string
	// Title describes the change.
	Title string
	// Files contains generated contents.
	Files []File
	// Parent identifies the preceding change when HasParent is true.
	Parent Change
	// HasParent distinguishes a stack link from a change on the source's base.
	HasParent bool
	// Note reports progress and may be called concurrently.
	Note func(string, ...any)
}

ChangeSpec describes a new change. Sources own their configured base.

type Dependencies

type Dependencies struct {
	// Source is required for generation, unused by RunExisting.
	Source Source
	// Gateway is required when Land is enabled.
	Gateway Gateway
	// Readiness is optional; nil means no preparation is required.
	Readiness Readiness
}

Dependencies supplies provider, transport and readiness integration.

type File

type File struct {
	// Path is relative to the repository root.
	Path string
	// Body is the complete file content.
	Body string
	// Message is the description when a provider commits files individually.
	Message string
}

File is one generated file and its source-specific commit description.

type Gateway

type Gateway interface {
	Land(ctx context.Context, queue string, uris []string, strategy mergestrategypb.Strategy) (requestID string, err error)
	History(ctx context.Context, queue, requestID string) ([]*pb.HistoryEvent, error)
}

Gateway is the transport-independent submission and history contract.

type Options

type Options struct {
	// Count is the number of changes to generate.
	Count int
	// Folders is the shard count; zero selects a reproducible count for the run.
	Folders int
	// Files is the minimum number of files per generated change.
	Files int
	// Concurrency bounds independent creation, readiness and submission.
	Concurrency int
	// Stacked submits an ordered chain as one request.
	Stacked bool
	// Burst prepares all independent changes before submitting any.
	Burst bool
	// Prefix is the generated branch namespace.
	Prefix string
	// RunID identifies a workload; empty generates a unique identifier.
	RunID string
	// Land enables submission; false only creates changes.
	Land bool
	// Watch waits for terminal request histories when Land is true.
	Watch bool
	// Queue is the exact queue accepting the requests.
	Queue string
	// Strategy is the wire strategy used for every submitted URI.
	Strategy mergestrategypb.Strategy
}

Options controls a workload, independently of its provider and transport.

type Readiness

type Readiness interface {
	Wait(context.Context, Change) error
}

Readiness waits for an exact revision to be eligible for submission.

type RequestResult

type RequestResult struct {
	// Changes is the ordered set submitted in this request.
	Changes []Change
	// ID is opaque and only meaningful together with the run's queue.
	ID string
	// Status is the last observed server status, not a local monitoring verdict.
	Status string
	// History is the last successful history read.
	History []*pb.HistoryEvent
}

RequestResult records one accepted request and its observed history.

type RunResult

type RunResult struct {
	// Changes contains known artifacts in input order, including unconfirmed branches.
	Changes []Change
	// Requests contains accepted requests in workload order.
	Requests []RequestResult
}

RunResult preserves known artifacts, including after a partially failed run.

func Run

func Run(ctx context.Context, opts Options, deps Dependencies) (RunResult, error)

Run generates a workload. Returned artifacts remain available on failure.

func RunExisting

func RunExisting(ctx context.Context, opts Options, changes []Change, deps Dependencies) (RunResult, error)

RunExisting submits existing changes in caller order without invoking Source. Each input must pin its revision. Stack ancestry is the caller's responsibility.

type Source

type Source interface {
	Open(context.Context, ChangeSpec) (Change, error)
}

Source creates independent changes concurrently and stack links sequentially.

Directories

Path Synopsis
Command requests supplies OSS providers and transport to the shared demo runner.
Command requests supplies OSS providers and transport to the shared demo runner.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL