dependencyanalysis

package
v0.3.0-20260820034428-... Latest Latest
Warning

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

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

Documentation

Overview

Package dependencyanalysis decides which batch carries a request, resolves what that batch must serialize behind, and promotes it from Creating to Created.

Why this is its own stage

Created is dependency-eligible: the next batch's analysis will pick it up and serialize behind it. A batch may therefore only reach Created if it is certain to be admitted afterwards, or it becomes a permanent dependency nothing can resolve and the queue wedges behind it.

Everything that makes a batch real happens here, in one stage: the enrolment decision, the association, the request claim, the dependency set, and the promotion. The batch stage upstream only mints an ID and hands it over, so a redelivery there costs an unreachable Creating row and nothing else — which is what lets this stage be the single place that decides.

Partitioning

Messages must be partitioned by queue. Analysis reads the queue's dependency-eligible batches, so two batches of one queue analyzed concurrently would each see the other still in Creating, neither would serialize behind the other, and both would speculate as though the other did not exist. Serial consumption is also what makes the enrolment check safe: it reads, decides and writes without another batch of the same queue interleaving.

Idempotency

Redelivery is expected and every step tolerates it. A batch already past Creating skips analysis entirely and only re-announces. Within analysis, the reverse-index and association writes are individually idempotent, because a failure part-way through leaves the state at Creating and the retry re-enters here.

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 dependency-analysis queue messages.

func NewController

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

NewController creates a new dependency-analysis 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 enrols a batch's requests, resolves its dependencies, promotes it to Created, and hands it to speculate. 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