Skip to content

Commit 2e020ac

Browse files
committed
Added getWorkflowId to route messages to specific workflow
1 parent dac4957 commit 2e020ac

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/packages/emmett/src/workflows/workflow.unit.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ export const decide = (
211211
}
212212
case 'GuestCheckedOut':
213213
case 'GuestCheckoutFailed': {
214-
return onCheckoutFinished(input, state);
214+
return completeGroupCheckout(input, state);
215215
}
216216
case 'TimeoutGroupCheckout': {
217217
return timedOut(input, state);
@@ -240,6 +240,7 @@ export const GroupCheckoutWorkflow: Workflow<
240240
export const groupCheckoutWorkflowProcessor = workflowProcessor({
241241
processorId: 'GroupCheckoutWorkflow',
242242
workflow: GroupCheckoutWorkflow,
243+
getWorkflowId: (input) => input.data.groupCheckoutId ?? null,
243244
inputs: {
244245
commands: ['InitiateGroupCheckout', 'TimeoutGroupCheckout'],
245246
events: ['GuestCheckedOut', 'GuestCheckoutFailed'],
@@ -289,7 +290,7 @@ const initiateGroupCheckout = (
289290
];
290291
};
291292

292-
const onCheckoutFinished = (
293+
const completeGroupCheckout = (
293294
{ type, data }: GuestCheckedOut | GuestCheckoutFailed,
294295
state: GroupCheckout,
295296
): GroupCheckoutCompleted | GroupCheckoutFailed | [] => {

src/packages/emmett/src/workflows/workflowProcessor.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ export type WorkflowOptions<
3434
'type' | 'canHandle'
3535
> & {
3636
workflow: Workflow<Input, State, Output>;
37+
getWorkflowId: (
38+
input: RecordedMessage<Input, MessageMetadataType>,
39+
) => string | null;
3740
inputs: {
3841
commands: CanHandle<WorkflowCommand<Input>>;
3942
events: CanHandle<WorkflowEvent<Input>>;

0 commit comments

Comments
 (0)