Skip to content

Commit

Permalink
Add metrics to queue status
Browse files Browse the repository at this point in the history
  • Loading branch information
burkaygur committed Nov 18, 2023
1 parent 7f2bb5e commit 26cc733
Showing 1 changed file with 36 additions and 28 deletions.
64 changes: 36 additions & 28 deletions libs/client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,25 @@ export type RequestLog = {
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;
};

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 @@ -44,22 +52,22 @@ export type ValidationErrorInfo = {
*/
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;
};

0 comments on commit 26cc733

Please sign in to comment.