atombeak
Version:
Create asynchronous atomic functions!
36 lines (35 loc) • 1.51 kB
TypeScript
import { Message } from './Message';
import { Command } from './Command';
import { Log } from '../Log';
export declare class Retry<Outer, Inner, Action> {
private readonly previousAttempt;
private readonly oldLog;
constructor(previousAttempt: number, oldLog: Log<Outer, Action>);
next(message: Message<Outer, Inner, Action>): [TransactionState<Outer, Inner, Action>, Command<Outer, Inner, Action>];
}
export declare class Pending<Outer, Inner, Action> {
private readonly attempt;
private readonly intermediateLog;
private readonly intermediateOuters;
constructor(attempt: number, intermediateLog: Log<Outer, Action>, intermediateOuters: Outer[]);
next(message: Message<Outer, Inner, Action>): [TransactionState<Outer, Inner, Action>, Command<Outer, Inner, Action>];
private restartWith;
}
export declare class Done<Outer, Inner, Action> {
private readonly attempt;
private readonly log;
constructor(attempt: number, log: Log<Outer, Action>);
getActions(): Action[];
next(message: Message<Outer, Inner, Action>): [TransactionState<Outer, Inner, Action>, Command<Outer, Inner, Action>];
}
/**
* Represents the state in which a transaction can be.
* The transaction is either:
*
* 1. Idle, and waiting for the `Outer` to change (meaningfully) to restart.
*
* 2. Pending
*
* 3. Done
*/
export declare type TransactionState<Outer, Inner, Action> = Retry<Outer, Inner, Action> | Pending<Outer, Inner, Action> | Done<Outer, Inner, Action>;