saga

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package saga drives the sagas (invariant I5): it looks at the open sagas again and again and does what each one needs next.

Input: the sagas in the database (created by erp.create_sales_order and wms.reserve) and the facts about their steps. Output: changes to the sagas, written by store.AdvanceSaga, and the 856, which this package asks for when the shipment is done and the warehouse has given its facts. The decisions themselves are in internal/store (decide); here are the loop, the two outside questions (what the warehouse recorded, whether an effect exists), and the time limits.

The runner keeps no state of its own. Any number of processes may run it: a saga that another one is working on is skipped.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Facts

type Facts interface {
	Shipment(ctx context.Context, externalID string) (adapters.Shipment, error)
}

Facts gives the facts the warehouse recorded about a shipment.

type Runner

type Runner struct {
	Store   *store.Store
	Adapter adapters.Adapter // asked whether an effect exists, for a step that failed without an answer
	Facts   Facts
	Policy  tools.Decider // decides the 856 (it is a tool call of the saga itself)
	Scale   float64       // the time limits are divided by it (EDIGATE_TIME_SCALE); 0 means 1
	Log     *slog.Logger

	// AckTimeout is how long a sent document waits for its 997. Zero means 24 hours divided
	// by Scale, but not less than 60 seconds.
	AckTimeout time.Duration
	// Poll is the pause between two passes; zero means half a second.
	Poll time.Duration
}

Runner advances the sagas.

func (*Runner) Pass

func (r *Runner) Pass(ctx context.Context) (int, error)

Pass advances every open saga once and returns how many changed.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context)

Run passes over the open sagas until ctx ends.

Jump to

Keyboard shortcuts

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