Documentation
¶
Index ¶
- func IsBatchStateHalted(s BatchState) bool
- func IsRequestStateHalted(s RequestState) bool
- func IsRequestStateTerminal(s RequestState) bool
- type Author
- type Batch
- type BatchChanges
- type BatchDependent
- type BatchID
- type BatchOutcome
- type BatchState
- type Build
- type BuildID
- type BuildMetadata
- type BuildStatus
- type CancelRequest
- type ChangeDetails
- type ChangeInfo
- type ChangeOutcome
- type ChangeRecord
- type ChangedFile
- type Conflict
- type ConflictType
- type GetRequestHistoryByChangeURIRequest
- type GetRequestHistoryByIDRequest
- type GetRequestSummaryByChangeURIRequest
- type GetRequestSummaryByIDRequest
- type LandRequest
- type LandResult
- type ListRequest
- type ListResult
- type MergeResult
- type OutcomeStatus
- type PushResult
- type QueueConfig
- type Request
- type RequestHistory
- type RequestID
- type RequestLog
- type RequestQueueSummary
- type RequestState
- type RequestStatus
- type RequestSummary
- type RequestURI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsBatchStateHalted ¶
func IsBatchStateHalted(s BatchState) bool
IsBatchStateHalted returns true if the batch is either terminal or in the process of being cancelled. Forward-progress controllers (score, build, buildsignal, speculate, merge) use this to short-circuit work for batches that the user has asked to cancel — even though Cancelling is non-terminal, no further pipeline work should start (cancel will write the terminal state and fan out).
func IsRequestStateHalted ¶
func IsRequestStateHalted(s RequestState) bool
IsRequestStateHalted returns true if the request is either terminal or in the process of being cancelled. Forward-progress controllers (validate, batch, ...) use this to short-circuit work for requests that the user has asked to cancel — even though Cancelling is non-terminal, no further pipeline work should start.
func IsRequestStateTerminal ¶
func IsRequestStateTerminal(s RequestState) bool
IsRequestStateTerminal returns true if the state represents a final, irreversible state (landed, error, or cancelled). RequestStateCancelling is intentionally excluded: cancellation is best-effort and a Cancelling request may still transition to Landed or Error before it reaches Cancelled. Callers that want to gate forward progress (and treat Cancelling as halted) should use IsRequestStateHalted instead.
Types ¶
type Author ¶
type Author struct {
// Name is the display name of the author.
Name string `json:"name"`
// Email is the email address of the author.
Email string `json:"email"`
}
Author represents the author of a change.
type Batch ¶
type Batch struct {
// ID is the globally unique identifier for the batch. Format: "<queue>/batch/<counter_value>".
ID string
// Queue is the name of the queue processing the land request. Queue name is defined in the configuration and should be unique within the system.
Queue string
// Contains is a list of land request IDs that are part of this batch.
// Request IDs will always be part of the same queue.
//
// For e.g. - [queueA/1, queueA/2, queueA/3].
//
Contains []string
// Dependencies is a list of other batch IDs that this batch depends on.
// Dependencies will always be part of the same queue. This way batches form a directed acyclic graph (DAG).
// If a batch A depends on batch B directly, it means that some request in batch A has overlapping changed targets with
// some another request in batch B. The Dependencies list contains all the transitive closure of all the dependencies, both direct and indirect.
// The order is not specified. Only active batches are considered for dependencies, i.e. if the batch is in a terminal state, it does not need to be included.
// Because batch states are eventually consistent, dependent batches identified at the time of batch creation may move to terminal states. The interpretation logic
// should reconcile batch states separately (i.e. ignore them for processing).
//
//This field is ok to be updated whether the state of the dependency graph changes. Update should use Version property for optimistic locking.
//
// Example: consider batches - queueA/batch/1, queueA/batch/2, queueA/batch/3
// such that - queueA/batch/2 and queueA/batch/3 have overlapping targets with requests in queueA/batch/1, but queueA/batch/2 and queueA/batch/3 do not have overlapping targets with each other.
//
// In this case, the Dependencies field for -
// - queueA/batch/1 will be empty
// - queueA/batch/2 will contain queueA/batch/1
// - queueA/batch/3 will contain queueA/batch/1
Dependencies []string
// Score is the predicted probability of build success for this batch, ranging from 0.0 to 1.0.
// Set during the scoring phase. Zero value means the batch has not been scored yet.
Score float64
// The state of the batch lifecycle this batch is in. Updateable field with Version for optimistic locking.
State BatchState
// Version is the version of the object. It is used for optimistic locking.
// Versioning starts at 1 and is incremented for each change to the object.
Version int32
}
Batch represents a group of requests to land (merge into target branch of the source control repository).
func BatchFromBytes ¶
BatchFromBytes deserializes a Batch from JSON bytes.
type BatchChanges ¶
type BatchChanges struct {
// BatchID is the batch being scored. Format: "<queue>/batch/<counter_value>".
BatchID string
// Queue is the queue the batch belongs to.
Queue string
// Changes is every change (URI + provider-supplied details) across all requests
// in the batch. Order is unspecified.
Changes []ChangeInfo
}
BatchChanges is the normalized, batch-level view of all changes in a batch: one ChangeInfo per claimed URI, aggregated across every request the batch contains. It is produced by the shared changeset resolver (Resolver.DetailedForBatch) and consumed by a Scorer. A Batch references only request IDs, so the resolver resolves each request's change records and flattens their details into Changes — giving the scorer the whole batch's change facts in one value without coupling it to storage.
func (BatchChanges) TotalFiles ¶
func (b BatchChanges) TotalFiles() int
TotalFiles returns the total number of files touched across every change in the batch.
func (BatchChanges) TotalLinesChanged ¶
func (b BatchChanges) TotalLinesChanged() int
TotalLinesChanged returns the total number of lines touched across every change in the batch.
type BatchDependent ¶
type BatchDependent struct {
// BatchID is the globally unique identifier of the upstream batch. Format: "<queue>/batch/<counter_value>".
BatchID string
// Dependents is a list of batch IDs that depend on this batch (i.e. batches whose Dependencies list contains BatchID).
// Updated as new batches are created that conflict with this batch. Uses Version for optimistic locking on updates.
Dependents []string
// Version is the version of the object. It is used for optimistic locking.
// Versioning starts at 1 and is incremented for each change to the object.
Version int32
}
BatchDependent is the reverse index of Batch.Dependencies. While Batch.Dependencies lists the batches a batch depends on (upstream), BatchDependent maps a batch to the batches that depend on it (downstream). This enables efficient fan-out notifications when a batch completes or fails — rather than scanning all batches to find which ones reference a given dependency, the system can look up dependents directly.
Example: consider batches queueA/batch/1, queueA/batch/2, queueA/batch/3 where batch/2 and batch/3 both depend on batch/1 (i.e. batch/1 is in their Dependencies list).
The BatchDependent records would be:
- BatchID=queueA/batch/1 → Dependents=[queueA/batch/2, queueA/batch/3]
- BatchID=queueA/batch/2 → Dependents=[] (nothing depends on it)
- BatchID=queueA/batch/3 → Dependents=[] (nothing depends on it)
type BatchID ¶
type BatchID struct {
// ID is the globally unique identifier for the batch.
ID string `json:"id"`
}
BatchID is a lightweight entity for publishing and consuming just the batch identifier via the queue.
func BatchIDFromBytes ¶
BatchIDFromBytes deserializes a BatchID from JSON bytes.
type BatchOutcome ¶
type BatchOutcome struct {
// BatchID is the input batch this outcome corresponds to.
BatchID string
// Outcomes is one entry per change in the batch, in apply order.
Outcomes []ChangeOutcome
}
BatchOutcome groups the per-change outcomes for a single pushed batch, so a merge-train push (several batches in one call) stays correlatable back to the batch each change belonged to. There is no per-batch status: a push is all-or-nothing across the whole call, so a per-batch pass/fail would be uniformly redundant.
type BatchState ¶
type BatchState string
BatchState defines the possible states of a batch.
const ( // BatchStateUnknown is the unreachable state. It is set by default when the structure is initialized. It should never be seen in the system. BatchStateUnknown BatchState = "" // BatchStateCreated is the state of a batch that has been created for processing. BatchStateCreated BatchState = "created" // BatchStateSpeculating is the state of a batch that is undergoing speculative execution. BatchStateSpeculating BatchState = "speculating" // BatchStateMerging is the state of a batch that is being merged after speculative execution. BatchStateMerging BatchState = "merging" // BatchStateSucceeded is the terminal state of a batch that has been successfully landed. BatchStateSucceeded BatchState = "succeeded" // BatchStateFailed is the terminal state of a batch that has failed. BatchStateFailed BatchState = "failed" // BatchStateScored is the state of a batch that has been scored for build success probability. BatchStateScored BatchState = "scored" // BatchStateCancelling is the non-terminal intent state set when a cancel has been requested but the // batch has not yet been transitioned to BatchStateCancelled. A batch in this state may still reach // BatchStateSucceeded or BatchStateFailed if a concurrent merge wins the race (e.g. the push had // already completed before the cancel CAS observed the batch); those terminal states prevail. // Forward-progress controllers must treat this state as halted (no new work). The speculate // controller owns the transition to the terminal BatchStateCancelled and the downstream fan-out // (cancelling in-flight builds, respeculating dependents, publishing to conclude). BatchStateCancelling BatchState = "cancelling" // BatchStateCancelled is the terminal state of a batch that was cancelled before completion. BatchStateCancelled BatchState = "cancelled" )
func ActiveBatchStates ¶
func ActiveBatchStates() []BatchState
ActiveBatchStates returns every non-terminal batch state that must be considered in-flight. Use this when callers need to find batches that still own a request, including Cancelling batches that cancel redelivery must be able to resolve.
func DependencyBatchStates ¶
func DependencyBatchStates() []BatchState
DependencyBatchStates returns the batch states that make an in-flight batch eligible to be a dependency of a newly created batch. When a batch is created, the conflict analyzer picks the existing batches it conflicts with as its dependencies; the new batch then speculates on top of them — it "bases" its speculative changes on the changes those batches are expected to land, so it must serialize behind them in the speculation graph.
Only batches still expected to land qualify. BatchStateCancelling is excluded (unlike ActiveBatchStates): a cancelling batch may never land, so basing new speculation on its changes would build on top of changes that can disappear.
func (BatchState) IsTerminal ¶
func (s BatchState) IsTerminal() bool
IsTerminal returns true if the batch state is a terminal state. Terminal states are states from which no further transitions are possible. BatchStateCancelling is intentionally excluded: cancellation is best-effort and a Cancelling batch may still transition to BatchStateSucceeded or BatchStateFailed before it reaches BatchStateCancelled. Callers that want to gate forward progress (and treat Cancelling as halted) should use IsBatchStateHalted instead.
type Build ¶
type Build struct {
// ID is the identifier minted by the queue's build runner when the build
// is triggered; this is the primary storage key.
ID string
// BatchID is the batch for which this build is scheduled.
BatchID string
// Status represents the state of the build lifecycle this build is in.
Status BuildStatus
}
Build represents a build scheduled for a batch along a specific speculation path. All fields except the Status are immutable after creation.
func BuildFromBytes ¶
BuildFromBytes deserializes a Build from JSON bytes.
type BuildID ¶
type BuildID struct {
// ID is the globally unique identifier for the build.
ID string `json:"id"`
}
BuildID is a lightweight entity for publishing and consuming just the build identifier via the queue.
func BuildIDFromBytes ¶
BuildIDFromBytes deserializes a BuildID from JSON bytes.
type BuildMetadata ¶
BuildMetadata carries provider-defined free-form metadata about a build (e.g. build URL, duration, commit SHA). Keys and values are implementation-defined; callers should not assume any particular schema.
type BuildStatus ¶
type BuildStatus string
BuildStatus defines the possible states of a build. The set is intentionally narrow: every supported build provider must be able to map its native lifecycle into one of these values without leaking provider-specific stages.
const ( // BuildStatusUnknown is the unreachable zero value, set by default when // the structure is initialized. It should never be seen in the system. BuildStatusUnknown BuildStatus = "" // BuildStatusAccepted indicates the build has been accepted for // execution. BuildStatusAccepted BuildStatus = "accepted" // BuildStatusRunning indicates the build is currently executing. BuildStatusRunning BuildStatus = "running" // BuildStatusSucceeded indicates the build completed successfully. // This is a terminal state. BuildStatusSucceeded BuildStatus = "succeeded" // BuildStatusFailed indicates the build did not complete successfully. // This is a terminal state. BuildStatusFailed BuildStatus = "failed" // BuildStatusCancelled indicates the build was cancelled. // This is a terminal state. BuildStatusCancelled BuildStatus = "cancelled" )
func (BuildStatus) IsTerminal ¶
func (s BuildStatus) IsTerminal() bool
IsTerminal returns true if the status represents a final state (Succeeded, Failed, or Cancelled).
type CancelRequest ¶
type CancelRequest struct {
// ID is the globally unique identifier of the request to cancel. Format: "<queue>/<counter_value>".
ID string `json:"id"`
// Reason is an optional free-form explanation of why the cancellation was requested.
Reason string `json:"reason"`
}
CancelRequest represents a cancellation request sent over the queue from the gateway to the orchestrator. It identifies the request to cancel by its ID and carries an optional human-readable reason for observability.
func CancelRequestFromBytes ¶
func CancelRequestFromBytes(data []byte) (CancelRequest, error)
CancelRequestFromBytes deserializes a CancelRequest from JSON bytes.
func (CancelRequest) ToBytes ¶
func (r CancelRequest) ToBytes() ([]byte, error)
ToBytes serializes the CancelRequest to JSON bytes for queue message payload.
type ChangeDetails ¶
type ChangeDetails struct {
// Author is the author of the change.
Author Author `json:"author"`
// ChangedFiles is the list of files modified in this change. Order is unspecified.
ChangedFiles []ChangedFile `json:"changed_files,omitempty"`
}
ChangeDetails holds the provider-supplied facts about a single change (author, modified files, line counts). It carries no identity — the owning URI lives on ChangeInfo (provider correlation) and ChangeRecord (persisted claim).
func (ChangeDetails) FileCount ¶
func (d ChangeDetails) FileCount() int
FileCount returns the number of files touched in the change.
func (ChangeDetails) TotalLinesChanged ¶
func (d ChangeDetails) TotalLinesChanged() int
TotalLinesChanged returns the total number of lines touched across all files in the change.
type ChangeInfo ¶
type ChangeInfo struct {
// URI is the full change URI for correlation with the input request
// (e.g., "github://github.example.com/uber/repo/pull/98/c3a4d5e6f7890123456789abcdef0123456789ab").
URI string `json:"uri"`
// Details is the provider-supplied facts for this URI.
Details ChangeDetails `json:"details"`
}
ChangeInfo maps a change URI to its details. It is the change provider's return type: for a Change with multiple URIs (e.g. a stacked PR set), the provider returns one ChangeInfo per URI so callers can correlate results to inputs by URI.
type ChangeOutcome ¶
type ChangeOutcome struct {
// Change is the input change this outcome corresponds to.
Change change.Change
// Status describes whether the change produced commits or was already
// present on the target branch.
Status OutcomeStatus
// CommitSHAs lists the commits this change produced on the target
// branch, in apply order. A single Change may produce multiple commits
// (e.g. a stack of PRs). Empty when Status is OutcomeStatusAlreadyExisted.
CommitSHAs []string
}
ChangeOutcome describes what happened to a single Change inside a push.
type ChangeRecord ¶
type ChangeRecord struct {
// URI identifies the change (RFC 3986). Same scheme/format as change.Change.URIs.
// Example: "github://github.example.com/uber/submitqueue/pull/123/c3a4d5e6f7890123456789abcdef0123456789ab".
URI string `json:"uri"`
// RequestID is the owning land request that claimed this URI.
// Format matches entity.Request.ID: "<queue>/<counter_value>".
//
// RequestID participates in the change-store primary key so that concurrent claims
// by different requests on the same URI coexist as distinct rows. Same-request
// retries collide on the PK and are absorbed idempotently; different-request
// collisions surface as additional rows that callers detect via GetByURI.
RequestID string `json:"request_id"`
// Queue is the queue the owning request belongs to. It is the leading column of
// the change-store primary key, so queue-scoped duplicate checks become PK-prefix
// scans and the table is shardable by queue.
Queue string `json:"queue"`
// Details holds the provider-supplied facts about the change (author, changed
// files, line counts). It is captured at claim time (the validate controller, after
// fetching from the change provider) and written once with the record — records are
// immutable, so Details is never updated after Create.
Details ChangeDetails `json:"details"`
// CreatedAt is the Unix milliseconds timestamp when this record was created.
CreatedAt int64 `json:"created_at"`
// UpdatedAt is the Unix milliseconds timestamp when this record was created. Records
// are immutable, so it always equals CreatedAt; retained for schema symmetry.
UpdatedAt int64 `json:"updated_at"`
// Version is the record version. Records are immutable, so it is always 1; retained
// for schema symmetry with the other stores.
Version int32 `json:"version"`
}
ChangeRecord represents a single URI's claim by a request, persisted in the change store. The whole record is immutable: the (Queue, URI, RequestID) triple is its identity and the Details (author, changed files, line counts) are captured once at claim time from the change provider. There is no update path.
type ChangedFile ¶
type ChangedFile struct {
// Path is the file path relative to the repository root.
Path string `json:"path"`
// LinesAdded is the number of lines added in this file.
LinesAdded int `json:"lines_added"`
// LinesDeleted is the number of lines deleted in this file.
LinesDeleted int `json:"lines_deleted"`
// LinesModified is the number of lines modified in this file. Some providers
// (e.g. GitHub) report only additions and deletions and leave this zero.
LinesModified int `json:"lines_modified"`
}
ChangedFile represents a single file modification in a change.
func (ChangedFile) TotalLines ¶
func (f ChangedFile) TotalLines() int
TotalLines returns the total number of lines touched in this file.
type Conflict ¶
type Conflict struct {
// BatchID is the ID of the in-flight batch that conflicts with the
// analyzed batch.
BatchID string
// Type classifies the conflict. A single (analyzed, in-flight) pair may
// be reported with multiple Conflict entries when different conflict
// types apply.
Type ConflictType
}
Conflict reports a single conflict between an analyzed batch and one of the in-flight batches.
type ConflictType ¶
type ConflictType string
ConflictType classifies why two batches are considered to conflict. New values may be added as more sophisticated analyzers are introduced.
const ( // ConflictTypeUnknown is the unreachable zero value, set by default when // the structure is initialized. It should never be seen in the system. ConflictTypeUnknown ConflictType = "" // ConflictTypeConservative means the analyzer treated the batches as // conflicting because it could not prove otherwise, without identifying a // specific reason. Used by conservative analyzers that serialize // everything by default. ConflictTypeConservative ConflictType = "conservative" // ConflictTypeTargetOverlap means the two batches modify one or more of // the same build targets and may therefore interfere with each other. ConflictTypeTargetOverlap ConflictType = "target_overlap" )
type GetRequestHistoryByChangeURIRequest ¶
type GetRequestHistoryByChangeURIRequest struct {
// ChangeURI is the exact change URI supplied in a Land request.
ChangeURI string
}
GetRequestHistoryByChangeURIRequest identifies retained histories by an exact pinned change URI.
type GetRequestHistoryByIDRequest ¶
type GetRequestHistoryByIDRequest struct {
// ID is the globally unique identifier of the request.
ID string
}
GetRequestHistoryByIDRequest identifies one retained request history by request ID.
type GetRequestSummaryByChangeURIRequest ¶
type GetRequestSummaryByChangeURIRequest struct {
// ChangeURI is the exact change URI supplied in a Land request.
ChangeURI string
}
GetRequestSummaryByChangeURIRequest identifies request summaries by an exact pinned change URI.
type GetRequestSummaryByIDRequest ¶
type GetRequestSummaryByIDRequest struct {
// ID is the globally unique identifier of the request. Format: "<queue>/<counter_value>".
ID string
}
GetRequestSummaryByIDRequest identifies one request summary by sqid.
type LandRequest ¶
type LandRequest struct {
// ID is the globally unique identifier for the land request. Format: "<queue>/<counter_value>".
ID string `json:"id"`
// Queue is the name of the queue processing the land request.
Queue string `json:"queue"`
// Change is the set of code changes to land.
Change change.Change `json:"change"`
// LandStrategy is the source control integration strategy to use for this land operation.
LandStrategy mergestrategy.MergeStrategy `json:"land_strategy"`
}
LandRequest represents the gateway-owned fields of a land request sent over the queue to the orchestrator. It contains only the validated inputs and generated ID — the orchestrator is responsible for constructing the full Request entity with state machine fields.
func LandRequestFromBytes ¶
func LandRequestFromBytes(data []byte) (LandRequest, error)
LandRequestFromBytes deserializes a LandRequest from JSON bytes.
func (LandRequest) ToBytes ¶
func (r LandRequest) ToBytes() ([]byte, error)
ToBytes serializes the LandRequest to JSON bytes for queue message payload.
type LandResult ¶
type LandResult struct {
// ID is the globally unique identifier assigned to the accepted land request.
// Format: "<queue>/<counter_value>".
ID string
}
LandResult is the outcome of accepting a land request. It carries the ID the controller assigned to the request so the transport layer can echo it back to the caller.
type ListRequest ¶
type ListRequest struct {
// Queue is the exact queue to query.
Queue string
// ReceivedAtOrAfterMs is the inclusive lower receipt-time bound in Unix milliseconds.
ReceivedAtOrAfterMs int64
// ReceivedBeforeMs is the exclusive upper receipt-time bound in Unix milliseconds.
ReceivedBeforeMs int64
// PageSize is the maximum number of results to return. Zero selects the server default.
PageSize int32
// PageToken is an opaque continuation token from a previous result.
PageToken string
}
ListRequest defines one bounded queue receipt-history query.
type ListResult ¶
type ListResult struct {
// Requests are ordered by receipt time descending, then request ID descending.
Requests []RequestQueueSummary
// NextPageToken is an opaque continuation token. Empty means this is the last page.
NextPageToken string
}
ListResult contains one page of queue receipt history.
type MergeResult ¶
type MergeResult struct {
// Mergeable is true if the request's changes are expected to merge cleanly.
Mergeable bool
// Reason is a human-readable explanation when Mergeable is false.
// Empty when Mergeable is true.
Reason string
}
MergeResult holds the outcome of a mergeability check.
type OutcomeStatus ¶
type OutcomeStatus string
OutcomeStatus describes what happened to a single Change during a push.
const ( // OutcomeStatusUnknown is the unreachable zero value, set by default // when the structure is initialized. It should never be seen in the system. OutcomeStatusUnknown OutcomeStatus = "" // OutcomeStatusCommitted means the change produced one or more commits // on the target branch. CommitSHAs lists those commits in apply order. OutcomeStatusCommitted OutcomeStatus = "committed" // OutcomeStatusAlreadyExisted means the change produced no commits // because every part of it is already present in the target branch // (e.g. it previously landed via another path, or a prior change in // the same push subsumed it). CommitSHAs is empty for this status. // In git terms this is what a `cherry-pick` surfaces as "rebased out". OutcomeStatusAlreadyExisted OutcomeStatus = "already_existed" )
type PushResult ¶
type PushResult struct {
// Batches is one entry per pushed batch, in the same order as the batches
// passed to the push. The slice length equals the input length.
Batches []BatchOutcome
}
PushResult is the outcome of a successful push.
type QueueConfig ¶
type QueueConfig struct {
// Name uniquely identifies this queue within the system.
// Referenced by Request.Queue.
Name string `json:"name" yaml:"name"`
}
QueueConfig identifies a single submit queue. It is the registry of valid queue names; the gateway validates that a land request targets a known queue. All behavioral and VCS configuration lives in the extension factory implementations, which are constructed per integrator deployment — the system hands a factory only the queue name. Immutable after creation.
type Request ¶
type Request struct {
// ID is the globally unique identifier for the land request. Format: "<queue>/<counter_value>".
ID string `json:"id"`
// Queue is the name of the queue processing the land request. Queue name is defined in the configuration and should be unique within the system.
Queue string `json:"queue"`
// Change is a number of code changes (such as pull requests) to land into the target branch. Target branch is defined by the queue configuration.
Change change.Change `json:"change"`
// LandStrategy is the source control integration strategy to use for this land operation.
LandStrategy mergestrategy.MergeStrategy `json:"land_strategy"`
// State is the current state of the land request.
State RequestState `json:"state"`
// Version is the version of the object. It is used for optimistic locking.
// Versioning starts at 1 and is incremented for each change to the object.
Version int32 `json:"version"`
}
Request defines a request to land (merge into target branch of the source control repository) a set of code changes. The object is immutable after creation.
func RequestFromBytes ¶
RequestFromBytes deserializes a Request from JSON bytes.
type RequestHistory ¶
type RequestHistory struct {
// RequestID is the globally unique identifier of the request.
RequestID string
// Events are retained request-log events ordered chronologically.
Events []RequestLog
}
RequestHistory groups retained events for one request.
type RequestID ¶
type RequestID struct {
// ID is the globally unique identifier for the land request.
ID string `json:"id"`
}
RequestID is a lightweight entity for publishing and consuming just the request identifier via the queue.
func RequestIDFromBytes ¶
RequestIDFromBytes deserializes a RequestID from JSON bytes.
type RequestLog ¶
type RequestLog struct {
// RequestID is the ID of the request this log entry belongs to. References entity.Request.ID.
RequestID string `json:"request_id"`
// TimestampMs is the time this log entry was created, in milliseconds since Unix epoch.
TimestampMs int64 `json:"timestamp_ms"`
// Status is the request status at the time this log entry was created. It may contain requests states from the state machine and also display-friendly intermediate statuses.
Status RequestStatus `json:"status"`
// RequestVersion is the version of the request at the time this log entry was created.
// Zero if the version is not available.
RequestVersion int32 `json:"request_version"`
// LastError is the last error message associated with the status at the time of this log entry.
// Empty string if no error.
LastError string `json:"last_error"`
// Metadata is a set of key-value pairs providing additional context for this log entry.
// Empty map if no metadata.
Metadata map[string]string `json:"metadata"`
}
RequestLog is an append-only record that captures a point-in-time snapshot of a request's status for reconciliation purposes. It is stored in a separate database from the request store to support eventual consistency reconciliation.
func NewRequestLog ¶
func NewRequestLog(requestID string, status RequestStatus, requestVersion int32, lastError string, metadata map[string]string) RequestLog
NewRequestLog creates a new RequestLog with the given fields. TimestampMs is set to the current time. If metadata is nil, it will be initialized as an empty map. requestVersion is the version of the request entity, should only be set if reporting a request state as a status, otherwise it should be 0. lastError is the last error message associated with the status at the time of this log entry, empty string if no error. metadata is a set of key-value pairs providing additional context for this log entry. Not constrained to any specific format or schema, used for display or debugging purposes.
func RequestLogFromBytes ¶
func RequestLogFromBytes(data []byte) (RequestLog, error)
RequestLogFromBytes deserializes a RequestLog from JSON bytes. If metadata is absent from the JSON, it will be initialized as an empty map.
func (RequestLog) ToBytes ¶
func (r RequestLog) ToBytes() ([]byte, error)
ToBytes serializes the RequestLog to JSON bytes for queue message payload.
type RequestQueueSummary ¶
type RequestQueueSummary struct {
// RequestID is the globally unique request identifier.
RequestID string
// Queue is the queue supplied at receipt.
Queue string
// ChangeURIs are the change URIs supplied at receipt in caller order.
ChangeURIs []string
// ReceivedAtMs is the immutable receipt timestamp in Unix milliseconds.
ReceivedAtMs int64
// Status is the current customer-facing request status.
Status RequestStatus
// Version is copied from the authoritative RequestSummary and guards stale projection writers.
Version int32
// LastError is the error associated with the current status, or empty when absent.
LastError string
// Metadata is display and debugging metadata associated with the current status.
Metadata map[string]string
}
RequestQueueSummary is the queue-ordered projection returned by List.
type RequestState ¶
type RequestState string
RequestState defines the possible states of a land request. They are internal and used to implement a state machine. A separate RequestStatus type is used to track the customer-friendly status of a request.
const ( // RequestStateUnknown is the unreachable state. It is set by default when the structure is initialized. It should never be seen in the system. RequestStateUnknown RequestState = "" // RequestStateStarted is the initial state of a land request. It is confirmed by the system but the processing is not started yet. RequestStateStarted RequestState = "started" // RequestStateValidated indicates that the request has been validated (duplicate check, merge check etc.) successfully. RequestStateValidated RequestState = "validated" // RequestStateBatched indicates that the request has been claimed by the batch controller and enrolled in a // batch. The CAS-write of this state by the batch controller is the serialization point between batch and // cancel: the batch controller transitions Validated → Batched immediately before persisting the new batch, // so any concurrent cancel that has already transitioned the request to Cancelling will lose the CAS and // abandon the batch. From this state forward, the request's terminal outcome is owned by the batch it is // enrolled in (via conclude), not by the cancel controller's request-only fast path. RequestStateBatched RequestState = "batched" // RequestStateProcessing is the state of a land request that is being processed. RequestStateProcessing RequestState = "processing" // RequestStateLanded is the state of a land request that has been successfully processed and landed. This is the final state. RequestStateLanded RequestState = "landed" // RequestStateError is the state of a land request that has encountered an error. This is the final state. RequestStateError RequestState = "error" // RequestStateCancelling is the non-terminal intent state set when the user has requested cancellation but the // request has not yet been transitioned to RequestStateCancelled. A request in this state may still reach // RequestStateLanded or RequestStateError if a concurrent merge or failure wins the race; those terminal // states prevail. Forward-progress controllers must treat this state the same as terminal (i.e. do not start // any new work on the request). RequestStateCancelling RequestState = "cancelling" // RequestStateCancelled is the state of a land request that was cancelled by the user before it could land. This is the final state. RequestStateCancelled RequestState = "cancelled" )
type RequestStatus ¶
type RequestStatus string
RequestLogStatus defines the possible status of a request. Status is customer-friendly and can be displayed to the user. It is different from the request state, which is internal and used to implement a state machine. Request statuses can be generally added freely by the system without breaking the state machine. Some statuses correspond to the request state, in which case they should be supplemented with the request state version to be used for reconciliation. Other statuses are purely informational and can be added freely. Every status may be accompanied by a last error message and free-formmetadata in the Request Log. It will only be used for display or debugging purposes.
const ( // RequestStatusUnknown is the unknown sentinel status. It is set by default when the structure is initialized. It should never be seen in the system. RequestStatusUnknown RequestStatus = "" // RequestStatusAccepting is the internal status of a persisted Land receipt that has not yet been published to the processing pipeline. // Public read APIs must not expose requests that remain in this status. RequestStatusAccepting RequestStatus = "accepting" // RequestStatusAccepted indicates that the request has been published to the processing pipeline. RequestStatusAccepted RequestStatus = "accepted" // RequestStatusStarted is the initial status of a request. It corresponds to the RequestStateStarted state and typically set by the orchestrator service when the request is received and persisted to the operating database. RequestStatusStarted RequestStatus = "started" // RequestStatusValidating indicates that the request is currently being validated (e.g., duplicate check, merge check, etc.). RequestStatusValidating RequestStatus = "validating" // RequestStatusValidated indicates that the request has been validated (duplicate check, merge check etc.) successfully. It corresponds to the RequestStateValidated state. RequestStatusValidated RequestStatus = "validated" // RequestStatusBatching indicates that the request is waiting to be included in a batch. RequestStatusBatching RequestStatus = "batching" // RequestStatusBatched indicates that the request has been included in a new batch and will be sent to speculation. RequestStatusBatched RequestStatus = "batched" // RequestStatusScored indicates that the batch containing the request has been scored for build success probability. RequestStatusScored RequestStatus = "scored" // RequestStatusSpeculating indicates that the request is currently being speculated (e.g., speculative merge/rebase, etc.). RequestStatusSpeculating RequestStatus = "speculating" // RequestStatusSpeculated indicates that the request has been successfully speculated and is ready to be validated via a build system. RequestStatusSpeculated RequestStatus = "speculated" // RequestStatusBuilding indicates that the request is currently being built (e.g., CI/CD system is building the change on top of the speculation path). RequestStatusBuilding RequestStatus = "building" // RequestStatusBuilt indicates that the request has finished the build step successfully and can move to the next phase, either wait for other requests to finish or move to the land phase. RequestStatusBuilt RequestStatus = "built" // RequestStatusWaitingPath indicates that the request is waiting for other preceiding request in the same speculation path to finish. RequestStatusWaitingPath RequestStatus = "waitingpath" // RequestStatusLanding indicates that the request is actively being landed (e.g., source control operation is in progress to push the change to the target branch). RequestStatusLanding RequestStatus = "landing" // RequestStatusProcessing is the status of a request that is being processed. It corresponds to the RequestStateProcessing state. RequestStatusProcessing RequestStatus = "processing" // RequestStatusLanded indicates that the request has been successfully processed and landed. It corresponds to the RequestStateLanded state. RequestStatusLanded RequestStatus = "landed" // RequestStatusError indicates that the request has encountered an error. It corresponds to the RequestStateError state. RequestStatusError RequestStatus = "error" // RequestStatusCancelling indicates that the user has requested cancellation but the request has not yet transitioned // to the RequestStateCancelled state. Cancellation is best-effort: a request that has already been merged or that // races to completion before the cancel propagates through the pipeline may still land. Observers should treat this // as intent only and rely on RequestStatusCancelled (or RequestStatusLanded) for the terminal outcome. Emitted by // the gateway when the Cancel RPC is received. RequestStatusCancelling RequestStatus = "cancelling" // RequestStatusCancelled indicates that the request was cancelled by the user before it could land. It corresponds to the RequestStateCancelled state. RequestStatusCancelled RequestStatus = "cancelled" )
type RequestSummary ¶
type RequestSummary struct {
// RequestID is the globally unique request identifier.
RequestID string
// Queue is the queue supplied at receipt.
Queue string
// ChangeURIs are the change URIs supplied at receipt in caller order.
ChangeURIs []string
// ReceivedAtMs is the immutable receipt timestamp in Unix milliseconds.
ReceivedAtMs int64
// Status is the current customer-facing request status.
Status RequestStatus
// RequestVersion is the orchestrator request version carried by the winning log entry, or zero when unavailable.
RequestVersion int32
// StatusTimestampMs is the timestamp of the winning log entry in Unix milliseconds.
StatusTimestampMs int64
// Version is the optimistic-lock version of this materialized view.
Version int32
// LastError is the error associated with the current status, or empty when absent.
LastError string
// Metadata is display and debugging metadata associated with the current status.
Metadata map[string]string
}
RequestSummary is the gateway-owned materialized current view of a request. RequestID is exposed as sqid by the gateway API.
type RequestURI ¶
type RequestURI struct {
// ChangeURI is the exact canonical URI supplied at receipt.
ChangeURI string
// ReceivedAtMs is the immutable receipt timestamp in Unix milliseconds.
ReceivedAtMs int64
// RequestID is the globally unique request identifier.
RequestID string
}
RequestURI maps one change URI to one received request.