Skip to content

Commit c436a90

Browse files
committed
Added reply method to notify service.
Don't trigger 'process.stepped' event when current state hasn't changed.
1 parent 2b60646 commit c436a90

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/notify/notify.service.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ export class NotifyService implements NotifyProvider {
2626
}
2727
}
2828

29+
@OnEvent('process.retry')
30+
async onRetry({ process, services }: { process: Process; services?: string[] }) {
31+
for (const args of process.current.notify) {
32+
if (!services && !services.includes(args.service)) continue;
33+
await this.notify(process, args);
34+
}
35+
}
36+
2937
async notify(process: Process, args: Notify): Promise<void> {
3038
try {
3139
const response = await this.getProvider(args.service).notify(process, args);
@@ -52,7 +60,7 @@ export class NotifyService implements NotifyProvider {
5260
case 'zeromq':
5361
return this.zeromq;
5462
default:
55-
throw new Error(`Unsupported provider ${settings.provider} for service '${service}'`);
63+
throw new Error(`Unsupported provider '${settings.provider}' for service '${service}'`);
5664
}
5765
}
5866
}

src/process/process.service.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ export class ProcessService {
185185
const updatedProcess = step(process, action, actor, response);
186186
await this.save(updatedProcess);
187187

188-
this.eventEmitter.emit('process.stepped', updatedProcess);
188+
if (process.current.timestamp.getTime() !== updatedProcess.current.timestamp.getTime()) {
189+
this.eventEmitter.emit('process.stepped', updatedProcess);
190+
}
191+
}
192+
193+
async retry(process: Process, services?: string[]) {
194+
this.eventEmitter.emit('process.retry', { process, services });
189195
}
190196
}

0 commit comments

Comments
 (0)