mirror of
https://github.com/documenso/documenso.git
synced 2025-11-15 01:01:49 +10:00
fix: improve inngest support
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
import { match } from 'ts-pattern';
|
||||
|
||||
import type { JobDefinition, TriggerJobOptions } from './_internal/job';
|
||||
import type { BaseJobProvider as JobClientProvider } from './base';
|
||||
import { InngestJobProvider } from './inngest';
|
||||
import { LocalJobProvider } from './local';
|
||||
import { TriggerJobProvider } from './trigger';
|
||||
|
||||
@ -9,35 +12,20 @@ export class JobClient<T extends Array<JobDefinition> = []> {
|
||||
private _provider: JobClientProvider;
|
||||
|
||||
public constructor(definitions: T) {
|
||||
if (process.env.NEXT_PRIVATE_JOBS_PROVIDER === 'trigger') {
|
||||
this._provider = TriggerJobProvider.getInstance();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._provider = LocalJobProvider.getInstance();
|
||||
this._provider = match(process.env.NEXT_PRIVATE_JOBS_PROVIDER)
|
||||
.with('inngest', () => InngestJobProvider.getInstance())
|
||||
.with('trigger', () => TriggerJobProvider.getInstance())
|
||||
.otherwise(() => LocalJobProvider.getInstance());
|
||||
|
||||
definitions.forEach((definition) => {
|
||||
this._provider.defineJob(definition);
|
||||
});
|
||||
}
|
||||
|
||||
// public static getInstance() {
|
||||
// if (!this._instance) {
|
||||
// this._instance = new JobClient();
|
||||
// }
|
||||
|
||||
// return this._instance;
|
||||
// }
|
||||
|
||||
public async triggerJob(options: TriggerJobOptions<T>) {
|
||||
return this._provider.triggerJob(options);
|
||||
}
|
||||
|
||||
// public defineJob<N extends string, T>(job: JobDefinition<N, T>) {
|
||||
// return this._provider.defineJob(job);
|
||||
// }
|
||||
|
||||
public getApiHandler() {
|
||||
return this._provider.getApiHandler();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user