@hotmeshio/hotmesh
Version:
Serverless Workflow
112 lines (111 loc) • 5.61 kB
TypeScript
import { CollationStage } from '../../types/collator';
import { ActivityDuplex } from '../../types/activity';
import { HotMeshGraph } from '../../types/hotmesh';
import { ProviderTransaction } from '../../types/provider';
import { Activity } from '../activities/activity';
import { Cycle } from '../activities/cycle';
declare class CollatorService {
static targetLength: number;
/**
* Upon re/entry, verify that the job status is active
*/
static assertJobActive(status: number, jobId: string, activityId: string, threshold?: number): void;
/**
* returns the dimensional address (dad) for the target; due
* to the nature of the notary system, the dad for leg 2 entry
* must target the `0` index while leg 2 exit must target the
* current index (0)
*/
static getDimensionalAddress(activity: Activity, isEntry?: boolean): Record<string, string>;
/**
* resolves the dimensional address for the
* ancestor in the graph to go back to. this address
* is determined by trimming the last digits from
* the `dad` (including the target).
* the target activity index is then set to `0`, so that
* the origin node can be queried for approval/entry.
*/
static resolveReentryDimension(activity: Cycle): string;
static notarizeEntry(activity: Activity, transaction?: ProviderTransaction): Promise<number>;
static authorizeReentry(activity: Activity, transaction?: ProviderTransaction): Promise<number>;
static notarizeEarlyExit(activity: Activity, transaction?: ProviderTransaction): Promise<number>;
static notarizeEarlyCompletion(activity: Activity, transaction?: ProviderTransaction): Promise<number>;
/**
* sets the synthetic inception key (in case of an overage occurs).
*/
static notarizeInception(activity: Activity, guid: string, transaction: ProviderTransaction): Promise<void>;
/**
* ignore those ID collisions that are due to re-entry overages
*/
static isInceptionOverage(activity: Activity, guid: string): Promise<boolean>;
/**
* verifies both the concrete and synthetic keys for the activity; concrete keys
* exist in the original model and are effectively the 'real' keys. In reality,
* hook activities are atomized during compilation to create a synthetic DAG that
* is used to track the status of the graph in a distributed environment. The
* synthetic key represents different dimensional realities and is used to
* track re-entry overages (it distinguishes between the original and re-entry).
* The essential challenge is: is this a re-entry that is purposeful in
* order to induce cycles, or is the re-entry due to a failure in the system?
*/
static notarizeReentry(activity: Activity, guid: string, transaction?: ProviderTransaction): Promise<number>;
static notarizeContinuation(activity: Activity, transaction?: ProviderTransaction): Promise<number>;
static notarizeCompletion(activity: Activity, transaction?: ProviderTransaction): Promise<number>;
static getDigitAtIndex(num: number, targetDigitIndex: number): number | null;
static getDimensionalIndex(num: number): number | null;
static isDuplicate(num: number, targetDigitIndex: number): boolean;
static isInactive(num: number): boolean;
static isPrimed(amount: number, leg: ActivityDuplex): boolean;
/**
* During compilation, the graphs are compiled into structures necessary
* for distributed processing; these are referred to as 'synthetic DAGs',
* because they are not part of the original graph, but are used to track
* the status of the graph in a distributed environment. This check ensures
* that the 'synthetic key' is not a duplicate. (which is different than
* saying the 'key' is not a duplicate)
*/
static verifySyntheticInteger(amount: number): void;
static verifyInteger(amount: number, leg: ActivityDuplex, stage: CollationStage): void;
static getDimensionsById(ancestors: string[], dad: string): Record<string, string>;
/**
* All non-trigger activities are assigned a status seed by their parent
*/
static getSeed(): string;
/**
* All trigger activities are assigned a status seed in a completed state
*/
static getTriggerSeed(): string;
/**
* entry point for compiler-type activities. This is called by the compiler
* to bind the sorted activity IDs to the trigger activity. These are then used
* at runtime by the activities to track job/activity status.
* @param graphs
*/
static compile(graphs: HotMeshGraph[]): void;
/**
* binds the ancestor array to each activity.
* Used in conjunction with the dimensional
* address (dad). If dad is `,0,1,0,0` and the
* ancestor array is `['t1', 'a1', 'a2']` for
* activity 'a3', then the SAVED DAD
* will always have the trailing
* 0's removed. This ensures that the addressing
* remains consistent even if the graph changes.
* id DAD SAVED DAD
* * t1 => ,0 => [empty]
* * a1 => ,0,1 => ,0,1
* * a2 => ,0,1,0 => ,0,1
* * a3 => ,0,1,0,0 => ,0,1
*
*/
static bindAncestorArray(graphs: HotMeshGraph[]): void;
/**
* All activities exist on a dimensional plane. Zero
* is the default. A value of
* `AxY,0,0,0,0,1,0,0` would reflect that
* an ancestor activity was dimensionalized beyond
* the default.
*/
static getDimensionalSeed(index?: number): string;
}
export { CollatorService };