MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / RuntimeAPI

Class RuntimeAPI

packages/core/src/v3/runtime/index.ts:10–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8const NOOP_RUNTIME_MANAGER = new NoopRuntimeManager();
9
10export class RuntimeAPI {
11 private static _instance?: RuntimeAPI;
12
13 private constructor() {}
14
15 public static getInstance(): RuntimeAPI {
16 if (!this._instance) {
17 this._instance = new RuntimeAPI();
18 }
19
20 return this._instance;
21 }
22
23 public waitForDuration(ms: number): Promise<void> {
24 return this.#getRuntimeManager().waitForDuration(ms);
25 }
26
27 public waitUntil(date: Date): Promise<void> {
28 return this.#getRuntimeManager().waitUntil(date);
29 }
30
31 public waitForTask(params: { id: string; ctx: TaskRunContext }): Promise<TaskRunExecutionResult> {
32 return this.#getRuntimeManager().waitForTask(params);
33 }
34
35 public waitForBatch(params: {
36 id: string;
37 runs: string[];
38 ctx: TaskRunContext;
39 }): Promise<BatchTaskRunExecutionResult> {
40 return this.#getRuntimeManager().waitForBatch(params);
41 }
42
43 public setGlobalRuntimeManager(runtimeManager: RuntimeManager): boolean {
44 return registerGlobal(API_NAME, runtimeManager);
45 }
46
47 public disable() {
48 this.#getRuntimeManager().disable();
49 unregisterGlobal(API_NAME);
50 }
51
52 #getRuntimeManager(): RuntimeManager {
53 return getGlobal(API_NAME) ?? NOOP_RUNTIME_MANAGER;
54 }
55}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…