Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metrics to queue status #27

Merged
merged 2 commits into from
Nov 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 36 additions & 28 deletions libs/client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,27 @@
timestamp: string; // Using string to represent date-time format, but you could also use 'Date' type if you're going to construct Date objects.
};

export type Metrics = {
inference_time: number | null;
};

export type QueueStatus =
| {
status: 'IN_PROGRESS' | 'COMPLETED';
response_url: string;
logs: null | RequestLog[];
}
| {
status: 'IN_QUEUE';
queue_position: number;
response_url: string;
};
{
status: 'IN_PROGRESS';
response_url: string;
logs: null | RequestLog[];
} | {
status: 'COMPLETED';
response_url: string;
logs: null | RequestLog[];
metrics: Metrics;
} | {
status: 'IN_QUEUE';
queue_position: number;
response_url: string;
};

export function isQueueStatus(obj: any): obj is QueueStatus {

Check warning on line 36 in libs/client/src/types.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
return obj && obj.status && obj.response_url;
}

Expand All @@ -42,24 +50,24 @@
* @template Payload - The type of the payload in the response. It defaults to `any`,
* allowing for flexibility in specifying the structure of the payload.
*/
export type WebHookResponse<Payload = any> =

Check warning on line 53 in libs/client/src/types.ts

View workflow job for this annotation

GitHub Actions / build

Unexpected any. Specify a different type
| {
/** Indicates a successful response. */
status: 'OK';
/** The payload of the response, structure determined by the Payload type. */
payload: Payload;
/** Error is never present in a successful response. */
error: never;
/** The unique identifier for the request. */
request_id: string;
}
/** Indicates a successful response. */
status: 'OK';
/** The payload of the response, structure determined by the Payload type. */
payload: Payload;
/** Error is never present in a successful response. */
error: never;
/** The unique identifier for the request. */
request_id: string;
}
| {
/** Indicates an unsuccessful response. */
status: 'ERROR';
/** The payload of the response, structure determined by the Payload type. */
payload: Payload;
/** Description of the error that occurred. */
error: string;
/** The unique identifier for the request. */
request_id: string;
};
/** Indicates an unsuccessful response. */
status: 'ERROR';
/** The payload of the response, structure determined by the Payload type. */
payload: Payload;
/** Description of the error that occurred. */
error: string;
/** The unique identifier for the request. */
request_id: string;
};
Loading