From f9e9df7928fce8ecd9e5bef3fe0985ef1544751d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Genevi=C3=A8ve=20Bastien?= Date: Fri, 15 Jan 2021 14:22:52 -0500 Subject: [PATCH] Implement the health check service of the TSP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add the checkHealth method to request server's health status Signed-off-by: Geneviève Bastien --- src/models/health.ts | 10 ++++++++++ src/protocol/tsp-client.ts | 10 ++++++++++ 2 files changed, 20 insertions(+) create mode 100644 src/models/health.ts diff --git a/src/models/health.ts b/src/models/health.ts new file mode 100644 index 0000000..6010bca --- /dev/null +++ b/src/models/health.ts @@ -0,0 +1,10 @@ +/** + * Model for a server health status response + */ +export interface HealthStatus { + /** + * The server status + */ + status: 'UP' | 'DOWN'; + +} diff --git a/src/protocol/tsp-client.ts b/src/protocol/tsp-client.ts index d2cb6ef..e3d10ac 100644 --- a/src/protocol/tsp-client.ts +++ b/src/protocol/tsp-client.ts @@ -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 @@ -301,4 +302,13 @@ export class TspClient { const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/' + outputID + '/style'; return await RestClient.post>(url, parameters); } + + /** + * Check the health status of the server + * @returns The Health Status + */ + public async checkHealth(): Promise> { + const url = this.baseUrl + '/health'; + return RestClient.get(url); + } }