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,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 | 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 {
return obj && obj.status && obj.response_url;
Expand All @@ -44,22 +52,22 @@ export type ValidationErrorInfo = {
*/
export type WebHookResponse<Payload = any> =
| {
/** 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;
};