Skip to content

Commit

Permalink
fix(offset): use latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerald Baulig committed Feb 20, 2025
1 parent 8b6c056 commit b8073c8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cfg/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"localhost:29092"
]
},
"latestOffset": false,
"latestOffset": true,
"orderCreated": {
"messageObject": "io.restorecommerce.order.Order"
},
Expand Down
22 changes: 11 additions & 11 deletions src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1722,17 +1722,6 @@ export class OrderingService
}
);
}

Object.values(response_map).forEach(
item => {
if (item.status?.code !== 200 && 'INVALID' in this.emitters) {
this.orderingTopic.emit(this.emitters['INVALID'], item);
}
else if (item.payload?.order_state in this.emitters) {
this.orderingTopic.emit(this.emitters[item.payload.order_state], item.payload);
}
}
);

if (this.notification_service) {
this.logger?.debug('Send notifications on submit...');
Expand Down Expand Up @@ -1783,6 +1772,17 @@ export class OrderingService
}
));
}

await Promise.all(Object.values(response_map).map(
async item => {
if (item.status?.code !== 200 && 'INVALID' in this.emitters) {
await this.orderingTopic.emit(this.emitters['INVALID'], item);
}
else if (item.payload?.order_state in this.emitters) {
await this.orderingTopic.emit(this.emitters[item.payload.order_state], item.payload);
}
}
));
}
catch (error: any) {
response.operation_status = this.catchOperationError(error)?.operation_status;
Expand Down
2 changes: 1 addition & 1 deletion test/ordering-srv.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ describe('The Ordering Service:', () => {

for (let [sample_name, sample] of Object.entries(samples.orders.valid)) {
it(`should submit valid orders by sample: ${sample_name}`, async function() {
this.timeout(5000);
this.timeout(30000);
const response = await client.submit(sample);
should.equal(
response.operationStatus?.code,
Expand Down

0 comments on commit b8073c8

Please sign in to comment.