Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions src/models/health.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/**
* Model for a server health status response
*/
export interface HealthStatus {
/**
* The server status
*/
status: 'UP' | 'DOWN';
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying to understand. Why not a simple boolean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, is it possible for the server to be down and still answer DOWN ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's from the TSP. We may want to add more status eventually, like OVERLOADED!

And yes, a server that may offer many services could say, "no, I don't answer to trace queries right now". Not the current implementation, but some implementation may.


}
10 changes: 10 additions & 0 deletions src/protocol/tsp-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { OutputDescriptor } from '../models/output-descriptor';
import { EntryModel, Entry, EntryHeader } from '../models/entry';
import { TspClientResponse } from './tsp-client-response';
import { OutputStyleModel } from '../models/styles';
import { HealthStatus } from '../models/health';

/**
* Trace Server Protocol client
Expand Down Expand Up @@ -301,4 +302,13 @@ export class TspClient {
const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/' + outputID + '/style';
return await RestClient.post<GenericResponse<OutputStyleModel>>(url, parameters);
}

/**
* Check the health status of the server
* @returns The Health Status
*/
public async checkHealth(): Promise<TspClientResponse<HealthStatus>> {
const url = this.baseUrl + '/health';
return RestClient.get<HealthStatus>(url);
}
}