mediator

package
v1.4.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IncludesItemBurnRate

func IncludesItemBurnRate(includes []string) bool

IncludesItemBurnRate reports whether API includes request item.burn_rate.

func MaybeRecalculateAfterConsumption

func MaybeRecalculateAfterConsumption(
	ctx context.Context,
	repos domain.RepoFactory,
	accountID, itemID string,
	delta decimal.Decimal,
	actionType string,
)

MaybeRecalculateAfterConsumption enqueues a burn-rate recalculation when a consumption change log was recorded. The recompute runs off the caller's transaction via the outbox, so the shared rate row's lock is not held for the length of that transaction. Errors are traced but do not fail the caller's primary operation.

func NewBurnRateMed

func NewBurnRateMed(config *BurnRateMedConfig) domain.BurnRateMed

func NewEditAccessMed

func NewEditAccessMed(config *EditAccessMedConfig) domain.EditAccessMed

func NewIdempotencyMed

func NewIdempotencyMed(config *IdempotencyMedConfig) domain.IdempotencyMed

func NewMediatorFactory

func NewMediatorFactory() domain.MediatorFactory

func NewProductionFlowMed

func NewProductionFlowMed(repos domain.RepoFactory) domain.ProductionFlowMed

func NewReadAccessMed

func NewReadAccessMed(config *ReadAccessMedConfig) domain.ReadAccessMed

func NewSandboxMed

func NewSandboxMed(config *SandboxMedConfig) domain.SandboxMed

func RecordInventoryAuditTrail

func RecordInventoryAuditTrail(
	ctx context.Context,
	repos domain.RepoFactory,
	accountID, itemID string,
	delta decimal.Decimal,
	unitID, actionType string,
	scanningStationID *string,
	responsibleUserID *string,
) *apierror.APIError

RecordInventoryAuditTrail writes inventory_log and inventory_change_log after a mutation and recalculates burn rate when the change represents consumption.

func RecordInventoryAuditTrailOrLog

func RecordInventoryAuditTrailOrLog(
	ctx context.Context,
	repos domain.RepoFactory,
	accountID, itemID string,
	delta decimal.Decimal,
	unitID, actionType string,
	scanningStationID *string,
	responsibleUserID *string,
)

RecordInventoryAuditTrailOrLog traces errors from RecordInventoryAuditTrail without failing the caller.

func RecordInventoryAuditTrailWithLevel added in v1.1.11

func RecordInventoryAuditTrailWithLevel(
	ctx context.Context,
	repos domain.RepoFactory,
	accountID, itemID string,
	delta decimal.Decimal,
	level decimal.Decimal,
	unitID, actionType string,
	scanningStationID *string,
	responsibleUserID *string,
) *apierror.APIError

RecordInventoryAuditTrailWithLevel is RecordInventoryAuditTrail with the post-mutation level handed in rather than fetched. The batch-scan consumer computes every audited item's level in one batched read after all of a scan's mutations are written and passes it here, so a scan that audits N items no longer runs N ledger aggregations. RecordInventoryAuditTrail fetches the level itself and calls through to this, so its callers are unchanged.

func RefreshItemBurnRateAfterGet

func RefreshItemBurnRateAfterGet(
	ctx context.Context,
	repos domain.RepoFactory,
	meds domain.Mediators,
	accountID string,
	item *domain.Item,
	includes []string,
)

RefreshItemBurnRateAfterGet recalculates burn rate when item.burn_rate was included, then reloads item.BurnRate.

Types

type BurnRateMedConfig

type BurnRateMedConfig struct {
	// Repos (required) is the repository factory for burn-rate calculations.
	Repos domain.RepoFactory
}

type EditAccessMedConfig

type EditAccessMedConfig struct {
	// Repos (required) is the repository factory for access checks.
	Repos domain.RepoFactory
}

type IdempotencyMedConfig

type IdempotencyMedConfig struct {
	// Repos (required) is the repository factory for idempotency persistence.
	Repos domain.RepoFactory
}

type ReadAccessMedConfig

type ReadAccessMedConfig struct {
	// Repos (required) is the repository factory for access checks.
	Repos domain.RepoFactory
}

type SandboxMedConfig

type SandboxMedConfig struct {
	// Repos (required) is the repository factory for sandbox operations.
	Repos domain.RepoFactory
}

Jump to

Keyboard shortcuts

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