Bundle

Source: bundle.ts:70

What a bundle process provides to Airflow, and the thing that serves it.

A bundle entry point builds one, registers what it provides, and awaits serve() at module top level:

CODE
const dag = new Dag("my_dag");
dag.task("extract", extractFn);

const bundle = new Bundle();
bundle.register(dag);
await bundle.serve();

Registering holds no sockets and starts nothing, so a test can build a bundle and invoke a handler through getTaskHandler without any runtime in scope. Only serve() connects to Airflow.

Lookups delegate live to each Dag's task map, so tasks added to a Dag after registration are visible: the bundle records Dag identity, not a snapshot of its tasks.


Constructors

new Bundle(...items: Registerable[]): Bundle

Parameters

Returns

Bundle


Methods

getTaskHandler( dagId: string, taskId: string, ): TaskFunction | undefined

Look up a registered handler, the way the runtime dispatches a task. Returns undefined when no handler exists.

Parameters

  • dagId (string)
  • taskId (string)

Returns

register(...items: Registerable[]): void

Register what this bundle provides. Registering an already-registered dagId throws, and a call that throws registers none of its items.

The constructor covers the common case; this is for a bundle that collects what it provides across several modules.

Parameters

Returns

  • void

serve(): Promise<void>

Serve this bundle to Airflow. The entry point of a TypeScript Dag bundle.

A bundle process serves one supervisor request, so a second call, which would connect a second pair of sockets, is rejected. A call that fails is not a serve, and may be retried. Resolves once the supervisor has been sent the terminal frame for the work this process was started for, and the same call answers the build-time --airflow-metadata query airflow-ts-pack makes.

Everything this bundle provides must be registered before serve() is awaited: what is left out is not part of the bundle, and its tasks are marked removed at runtime.

Returns

  • Promise<void>