forked from NangoHQ/nango
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NAN-478] update runner logic to allow to connect to a remote instance (
NangoHQ#1768) ## Describe your changes * Add a remote instance runner so jobs doesn't need to spawn a process. In some cases I saw that a sync failed because spawning a process took too long. For enterprise customers they can setup a runner instance and so in that case jobs will connect to that remote instance instead. Customers can set this using the `RUNNER_SERVICE_URL` env variable * Best practice is to use an AWS role for connecting to a bucket so this update allows customers to configure bucket connection using the role as long as they have `AWS_REGION` and `AWS_BUCKET_NAME` set ## Issue ticket number and link NAN-478 ## Checklist before requesting a review (skip if just adding/editing APIs & templates) - [ ] I added tests, otherwise the reason is: - [ ] I added observability, otherwise the reason is: - [ ] I added analytics, otherwise the reason is:
- Loading branch information
1 parent
d7cf723
commit 7229b49
Showing
3 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import type { Runner } from './runner.js'; | ||
import { RunnerType } from './runner.js'; | ||
import { getRunnerClient } from '@nangohq/nango-runner'; | ||
|
||
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); | ||
} | ||
|
||
async suspend(): Promise<void> { | ||
console.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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters