Documentation
¶
Overview ¶
Package fault provides a state.Store implementation that wraps the in-memory store and lets tests deterministically inject transient transactional save failures keyed by a substring of the operation key. Tests use this to verify that workflow / actor code recovers cleanly from state-store hiccups (no stuck workflows, no orphan reminders).
Index ¶
- type Store
- func (s *Store) ArmETagMismatch(keySubstring string, n int, notify chan struct{})
- func (s *Store) ArmFailures(keySubstring string, n int, notify chan struct{})
- func (s *Store) FailedCount() int
- func (s *Store) Multi(ctx context.Context, req *state.TransactionalStateRequest) error
- func (s *Store) MultiMaxSize() int
- func (s *Store) SetMultiObserver(fn func(*state.TransactionalStateRequest))
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
Store wraps an in-memory state store and selectively fails Multi (transactional) operations whose keys contain a configured substring.
func New ¶
New returns a Store that is functionally identical to the in-memory store until ArmFailures is called.
func (*Store) ArmETagMismatch ¶ added in v1.18.0
ArmETagMismatch arms the store to return a state.ETagError of kind ETagMismatch on the next n matching Multi requests. Use this when a test wants to exercise the orchestrator's peer-write recovery path rather than a generic transient error.
func (*Store) ArmFailures ¶
ArmFailures arms the store to return a synthetic transient error on the next n transactional Multi requests whose operation keys contain keySubstring. n=1 produces a one-shot failure, n=0 disarms. If notify is non-nil it is closed the FIRST time a matching Multi is failed, so callers can synchronise on the failure firing.
func (*Store) FailedCount ¶
FailedCount returns the total number of Multi requests that have been failed by this Store since it was constructed.
func (*Store) Multi ¶
Multi implements state.TransactionalStore. If the store is armed and the request touches a key containing the armed substring, the request is failed with the armed error; otherwise the request is delegated to the underlying in-memory store.
func (*Store) MultiMaxSize ¶
MultiMaxSize advertises no per-transaction key limit so the test can freely batch saves through the in-memory implementation.
func (*Store) SetMultiObserver ¶ added in v1.18.0
func (s *Store) SetMultiObserver(fn func(*state.TransactionalStateRequest))
SetMultiObserver registers a callback invoked synchronously on every Multi before delegation. Tests use it to inspect the ETag of specific upserts. nil clears any previously registered observer.