Skip to content

Commit 4d570d3

Browse files
committed
Support customizing task pollInterval on server
1 parent b24ea0f commit 4d570d3

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

src/examples/server/simpleStreamableHttp.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,8 @@ const getServer = () => {
479479
})();
480480
return await taskStore.createTask({
481481
taskId,
482-
keepAlive: taskRequestedKeepAlive
482+
keepAlive: taskRequestedKeepAlive,
483+
pollInterval: 100
483484
});
484485
},
485486
async getTask(_args, { taskId, taskStore }) {

src/examples/shared/inMemoryTaskStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export class InMemoryTaskStore implements TaskStore {
3232
taskId,
3333
status: 'submitted',
3434
keepAlive: metadata.keepAlive ?? null,
35-
pollInterval: 500
35+
pollInterval: metadata.pollInterval ?? 500
3636
};
3737

3838
this.tasks.set(taskId, {

src/types.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,12 @@ export const TaskMetadataSchema = z
4444
/**
4545
* Time in milliseconds to ask to keep task results available after completion. Only used with taskId.
4646
*/
47-
keepAlive: z.number().optional()
47+
keepAlive: z.number().optional(),
48+
49+
/**
50+
* Time in milliseconds to wait between task status requests. Only used with taskId.
51+
*/
52+
pollInterval: z.optional(z.number())
4853
})
4954
/**
5055
* Passthrough required here because we want to allow any additional fields to be added to the request meta.

0 commit comments

Comments
 (0)