-
Notifications
You must be signed in to change notification settings - Fork 368
/
remote.runner.ts
33 lines (27 loc) · 987 Bytes
/
remote.runner.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import Logger from '@nangohq/utils/dist/logger.js';
import type { Runner } from './runner.js';
import { RunnerType } from './runner.js';
import { getRunnerClient } from '@nangohq/nango-runner';
const { logger } = new Logger('Jobs');
export class RemoteRunner implements Runner {
public client: any;
public runnerType: RunnerType = RunnerType.Remote;
constructor(
public readonly id: string,
public readonly url: string
) {
this.client = getRunnerClient(this.url);
}
suspend() {
logger.warn('cannot suspend a remote runner');
}
toJSON() {
return { runnerType: this.runnerType, id: this.id, url: this.url };
}
static fromJSON(obj: any): RemoteRunner {
throw new Error(`'fromJSON(${obj})' not implemented`);
}
static async getOrStart(runnerId: string): Promise<RemoteRunner> {
return new RemoteRunner(runnerId, process.env['RUNNER_SERVICE_URL'] || 'http://nango-runner');
}
}