Skip to content

Latest commit

 

History

History

examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Execution Engine Examples

Every file here runs on its own — npx ts-node examples/<file>.ts — and the ones that build a graph write their trace next to themselves as JSON. The Graph Results links open that JSON in the json-to-graph viewer.

The four marked docs are the ones shown on https://tabkram.github.io/execution-engine/examples, with their code beside the run they produced.

One function at a time

No engine and no graph: these wrap a single function and report what it did.

Example Code Output
execution-trace.ts execution-trace.json docs
execution-cache.ts prints to the console docs
execution-memoize.ts prints to the console docs
  • execution-trace.ts: executionTrace around one call — inputs, outputs, timing, returned as a record.
  • execution-cache.ts: @cache keyed on the arguments; the repeat call never reaches the API.
  • execution-memoize.ts: @memoize storing the in-flight promise, so twelve simultaneous callers share one execution.

A run as a graph

Example Code Trace Output Trace Graph
engine-checkout.ts engine-checkout.json Graph Results docs
engine-sequential.ts engine-sequential.json Graph Results
engine-recursive.ts engine-recursive.json Graph Results
authentication.ts authentication.json Graph Results
car.ts car.json Graph Results
usage.ts usage.json Graph Results
  • engine-sequential.ts: the smallest graph there is — four plain functions called through engine.run, four nodes, three inferred edges.
  • engine-checkout.ts: one checkout through @engine and @run that exercises everything at once — a chain, nesting, recursion, a @cache hit, a @memoized call, and a fork and join at the top level.
  • engine-recursive.ts: a dependency tree resolved by a method that calls itself, where @memoize means a package shared by three branches is walked once.
  • usage.ts: the fundamentals of ExecutionEngine in a dozen lines.
  • authentication.ts: sequential execution, with a detailed trace for each step.
  • car.ts: orchestrating tasks both simultaneously and hierarchically.

Decorator-based usage

  • usage2.ts: @engine and @run for a class-based approach.
  • weather.ts: custom parameters and options through decorators, including error handling.
  • usage3.ts: a deep workflow with consecutive tasks.
  • greeting.ts: traceOptions through decorators — extracting and reshaping what gets recorded.
Example Code Trace Output Trace Graph
usage2.ts usage2.json Graph Results
usage3.ts usage3.json Graph Results
weather.ts weather.json Graph Results
greeting.ts greeting.json Graph Results