Skip to content

Commit

Permalink
Add error handling around Temporal client operations.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyri113 committed Nov 16, 2024
1 parent e45f4da commit 4fd85fd
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions src/services/temporal/discourse.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@ import config from '../../config';

class TemporalDiscourseService extends TemporalCoreService {
public async createSchedule(platformId: string, endpoint: string): Promise<ScheduleHandle> {
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}`);
}
}
}

Expand Down

0 comments on commit 4fd85fd

Please sign in to comment.