Home/TypeScript and Go

Ship the graph in your language. Idle cost stays at zero.

The graph is a function. deploy() registers it, and the platform runs each node with retries, fan-out, and a live log. When the run finishes, there is no worker process left to pay for.

  1. 01

    Write it in TS or Go

    node() and graph() in TypeScript. gi.Node and gi.Graph in Go. Same shape: a function, a name, a retry policy.

  2. 02

    Call deploy()

    That call pushes the code. The platform builds the environment and runs the graph when a run starts.

  3. 03

    It runs, then it stops

    A run scales out for the work in front of it. After the last task, compute goes back to zero.

Paste this graph

Both snippets fetch two URLs in parallel, cache the fetch for an hour, and retry the graph twice. The full files are sdk/typescript/examples/no_workers.ts and sdk/go/examples/no_workers.go.

import { node, graph, deploy } from "graphingest";

const fetchPage = node(
  { name: "fetch-page", cacheTtl: 3600, maxRetries: 3 },
  async (url: string) => {
    const resp = await fetch(url);
    return { url, status: resp.status };
  }
);

const pipeline = graph(
  {
    name: "web-scraper",
    timeoutMs: 3_600_000,
    retryPolicy: { maxRetries: 2, delayMs: 1_000, backoffFactor: 2 },
  },
  async (urls: string[]) => {
    const pages = await fetchPage.map(urls);
    return { fetched: pages.length };
  }
);

await deploy();

Run it

  1. TypeScript: npm install graphingest, then npx tsx sdk/typescript/examples/no_workers.ts.
  2. Go: go get github.com/graphingest/graphingest-go, then go run sdk/go/examples/no_workers.go.
  3. Set GRAPHINGEST_API_KEY from Settings β†’ API Keys. After deploy(), the run is on the dashboard.