concurrency

package
v0.94.13 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNoOpFlusher

func NewNoOpFlusher(
	ctx context.Context,
	outbox pgoutbox.Outbox,
	strategy *sqlcv1.V1StepConcurrency,
	l *zerolog.Logger,
)

Types

type ConcurrencyStrategy

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

func NewConcurrencyStrategy

func NewConcurrencyStrategy(
	ctx context.Context,
	repo repository.ConcurrencyRepository,
	strategy *sqlcv1.V1StepConcurrency,
	outbox pgoutbox.Outbox,
	l *zerolog.Logger,
) *ConcurrencyStrategy

NewConcurrencyStrategy constructs a strategy index for a single (tenant, strategy) and registers it as the pgoutbox flusher for its topic (<tenant_id>.<strategy_id>). It kicks off the initial index hydration asynchronously on the provided (lifecycle) context, which must outlive any single Run - building can take much longer than a Run's deadline, and we must not abandon a partially-built index.

func (*ConcurrencyStrategy) Flush

Flush satisfies the pgoutbox.Flusher interface. It runs inside the same transaction pgoutbox uses to acquire and delete the messages, so the slot writes performed here commit (or roll back) atomically with the message delete. We unmarshal the WAL payloads, replay them into the index, and stash the result for Run to collect. If we return an error, pgoutbox rolls the transaction back and the messages are redelivered on a later Run.

func (*ConcurrencyStrategy) Run

Run drains the strategy's outbox topic, replaying every WAL message into the in-memory index and flushing the resulting slot decisions to the database. It returns the merged *repository.RunConcurrencyResult across all batches processed this tick.

Jump to

Keyboard shortcuts

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