diff --git a/src/services/temporal/discourse.service.ts b/src/services/temporal/discourse.service.ts index 8a070f5..85657de 100644 --- a/src/services/temporal/discourse.service.ts +++ b/src/services/temporal/discourse.service.ts @@ -4,24 +4,27 @@ import config from '../../config'; class TemporalDiscourseService extends TemporalCoreService { public async createSchedule(platformId: string, endpoint: string): Promise { - const client: Client = await this.getClient(); - - return client.schedule.create({ - action: { - type: 'startWorkflow', - workflowType: 'DiscourseExtractWorkflow', - args: [endpoint], // TODO add platformId - taskQueue: config.temporal.heavyQueue, - }, - scheduleId: `discourse/${encodeURIComponent(endpoint)}`, - policies: { - catchupWindow: '1 day', - overlap: ScheduleOverlapPolicy.SKIP, - }, - spec: { - intervals: [{ every: '1d' }], - }, - }); + try { + const client: Client = await this.getClient(); + return client.schedule.create({ + action: { + type: 'startWorkflow', + workflowType: 'DiscourseExtractWorkflow', + args: [endpoint], // TODO add platformId + taskQueue: config.temporal.heavyQueue, + }, + scheduleId: `discourse/${encodeURIComponent(endpoint)}`, + policies: { + catchupWindow: '1 day', + overlap: ScheduleOverlapPolicy.SKIP, + }, + spec: { + intervals: [{ every: '1d' }], + }, + }); + } catch (error) { + throw new Error(`Failed to create Temporal schedule: ${(error as Error).message}`); + } } }