feat(client): add metrics to queue status (#27)
* Add metrics to queue status * Update libs/client/src/types.ts Co-authored-by: Daniel Rochetti <daniel.rochetti@gmail.com> --------- Co-authored-by: Daniel Rochetti <daniel.rochetti@gmail.com>
This commit is contained in:
parent
7f2bb5e77d
commit
09c77be1f2
@ -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.
|
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 =
|
export type QueueStatus =
|
||||||
| {
|
{
|
||||||
status: 'IN_PROGRESS' | 'COMPLETED';
|
status: 'IN_PROGRESS';
|
||||||
response_url: string;
|
response_url: string;
|
||||||
logs: null | RequestLog[];
|
logs: null | RequestLog[];
|
||||||
}
|
} | {
|
||||||
| {
|
status: 'COMPLETED';
|
||||||
status: 'IN_QUEUE';
|
response_url: string;
|
||||||
queue_position: number;
|
logs: null | RequestLog[];
|
||||||
response_url: string;
|
metrics: Metrics;
|
||||||
};
|
} | {
|
||||||
|
status: 'IN_QUEUE';
|
||||||
|
queue_position: number;
|
||||||
|
response_url: string;
|
||||||
|
};
|
||||||
|
|
||||||
export function isQueueStatus(obj: any): obj is QueueStatus {
|
export function isQueueStatus(obj: any): obj is QueueStatus {
|
||||||
return obj && obj.status && obj.response_url;
|
return obj && obj.status && obj.response_url;
|
||||||
@ -44,22 +52,22 @@ export type ValidationErrorInfo = {
|
|||||||
*/
|
*/
|
||||||
export type WebHookResponse<Payload = any> =
|
export type WebHookResponse<Payload = any> =
|
||||||
| {
|
| {
|
||||||
/** Indicates a successful response. */
|
/** Indicates a successful response. */
|
||||||
status: 'OK';
|
status: 'OK';
|
||||||
/** The payload of the response, structure determined by the Payload type. */
|
/** The payload of the response, structure determined by the Payload type. */
|
||||||
payload: Payload;
|
payload: Payload;
|
||||||
/** Error is never present in a successful response. */
|
/** Error is never present in a successful response. */
|
||||||
error: never;
|
error: never;
|
||||||
/** The unique identifier for the request. */
|
/** The unique identifier for the request. */
|
||||||
request_id: string;
|
request_id: string;
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
/** Indicates an unsuccessful response. */
|
/** Indicates an unsuccessful response. */
|
||||||
status: 'ERROR';
|
status: 'ERROR';
|
||||||
/** The payload of the response, structure determined by the Payload type. */
|
/** The payload of the response, structure determined by the Payload type. */
|
||||||
payload: Payload;
|
payload: Payload;
|
||||||
/** Description of the error that occurred. */
|
/** Description of the error that occurred. */
|
||||||
error: string;
|
error: string;
|
||||||
/** The unique identifier for the request. */
|
/** The unique identifier for the request. */
|
||||||
request_id: string;
|
request_id: string;
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user