Skip to content

Commit

Permalink
Merge pull request #714 from isucon/feature/retry_after_ms.node
Browse files Browse the repository at this point in the history
feat(node): retry_after_msを返すように
  • Loading branch information
tohutohu authored Dec 7, 2024
2 parents f7a27b4 + 42aaf0e commit f471035
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion webapp/nodejs/src/app_handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ type AppGetNotificationResponseData = {

type AppGetNotificationResponse = {
data: AppGetNotificationResponseData;
retry_after_ms?: number;
};

export const appGetNotification = async (ctx: Context<Environment>) => {
Expand All @@ -508,7 +509,7 @@ export const appGetNotification = async (ctx: Context<Environment>) => {
[user.id],
);
if (!ride) {
return ctx.json({}, 200);
return ctx.json({ retry_after_ms: 30 }, 200);
}
const [[yetSentRideStatus]] = await ctx.var.dbConn.query<
Array<RideStatus & RowDataPacket>
Expand Down Expand Up @@ -546,6 +547,7 @@ export const appGetNotification = async (ctx: Context<Environment>) => {
created_at: ride.created_at.getTime(),
updated_at: ride.updated_at.getTime(),
},
retry_after_ms: 30,
};
if (ride.chair_id !== null) {
const [[chair]] = await ctx.var.dbConn.query<
Expand Down
3 changes: 2 additions & 1 deletion webapp/nodejs/src/chair_handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export const chairGetNotification = async (ctx: Context<Environment>) => {
[chair.id],
);
if (!ride) {
return ctx.json({}, 200);
return ctx.json({ retry_after_ms: 30 }, 200);
}

const [[yetSentRideStatus]] = await ctx.var.dbConn.query<
Expand Down Expand Up @@ -164,6 +164,7 @@ export const chairGetNotification = async (ctx: Context<Environment>) => {
},
status,
},
retry_after_ms: 30,
},
200,
);
Expand Down

0 comments on commit f471035

Please sign in to comment.