speculate

package
v0.3.0-20260807201250-... Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller handles speculate queue messages.

Naive happy-path algorithm: assume every in-flight build will pass and treat batch.Dependencies + [batch.ID] as the single speculation chain. Per invocation, the controller advances the batch one step in the state machine:

  • Created → publish to build, transition to Speculating.
  • Speculating → if all deps are Succeeded, publish to merge and transition to Merging; otherwise no-op (or fail-fast if a dep is in a non-succeeding terminal state).
  • Cancelling → cancel any in-flight Build entity, respeculate dependents, CAS to terminal Cancelled, publish to conclude. The cancel controller hands the batch off in this state and speculate drives it to terminal.
  • Merging → no-op (owned by the merge controller).
  • Terminal → re-fan-out to conclude for self-healing in case a prior publish was lost. For terminal Cancelled, also re-fan-out dependents so a crash between the terminal CAS and the dependent publish does not strand them.

The controller is re-triggered on every relevant downstream event (buildsignal, merge), so each call simply re-evaluates the current state and either advances or waits.

func NewController

func NewController(
	logger *zap.SugaredLogger,
	scope tally.Scope,
	stores storage.Factory,
	registry consumer.TopicRegistry,
	topicKey consumer.TopicKey,
	consumerGroup string,
) *Controller

NewController creates a new speculate controller for the orchestrator.

func (*Controller) ConsumerGroup

func (c *Controller) ConsumerGroup() string

ConsumerGroup returns the consumer group for offset tracking.

func (*Controller) Name

func (c *Controller) Name() string

Name returns the controller name for logging and metrics.

func (*Controller) Process

func (c *Controller) Process(ctx context.Context, delivery consumer.Delivery) error

Process advances a batch one step along the naive happy-path. Returns nil to ack (success), or error to nack (retry).

func (*Controller) TopicKey

func (c *Controller) TopicKey() consumer.TopicKey

TopicKey returns the topic key this controller subscribes to.

Jump to

Keyboard shortcuts

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