From 0eca3db4e825fb2596013468da59ac231b29bc60 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Wed, 6 Dec 2023 11:42:49 +0900 Subject: [PATCH 1/4] fix: isRunning return boolean and add checkRunning --- src/controllers/serviceController.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/controllers/serviceController.ts b/src/controllers/serviceController.ts index 64c580b..0371daf 100644 --- a/src/controllers/serviceController.ts +++ b/src/controllers/serviceController.ts @@ -17,13 +17,18 @@ export default class ServiceController { return ServiceController.instance; } - async isRunning(serviceName: string): Promise { - const isRunning = await this.ain.getValue(Path.app(serviceName).status()); - if(isRunning !== ContainerStatus.RUNNING) { - throw new Error('Service is not running'); + async checkRunning(serviceName: string): Promise { + const isRunning = await this.isRunning(serviceName); + if (!isRunning) { + throw new Error('Service is not running.'); } } + async isRunning(serviceName: string): Promise { + const runningStatus = await this.ain.getValue(Path.app(serviceName).status()); + return runningStatus === ContainerStatus.RUNNING ? true : false; + } + // TODO(woojae): implement this async getInformation(serviceName: string): Promise { return await 'information of service'; From 892ab9c45c48b5b1e4be3aee621adac8b0ddc69b Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Wed, 6 Dec 2023 11:46:33 +0900 Subject: [PATCH 2/4] fix: isRunning to checkRunning --- src/controllers/serviceController.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controllers/serviceController.ts b/src/controllers/serviceController.ts index 0371daf..a21c0d0 100644 --- a/src/controllers/serviceController.ts +++ b/src/controllers/serviceController.ts @@ -47,7 +47,7 @@ export default class ServiceController { } async chargeCredit(serviceName: string, amount: number): Promise { - this.isRunning(serviceName); + this.checkRunning(serviceName); const transferKey = Date.now(); const userAddress = this.ain.getAddress(); const depositAddress = await this.getDepositAddress(serviceName); @@ -77,7 +77,7 @@ export default class ServiceController { } async request(serviceName: string, requestData: string) : Promise { - this.isRunning(serviceName); + this.checkRunning(serviceName); const result = await new Promise(async (resolve, reject) => { const requestKey = Date.now(); const requesterAddress = this.ain.getAddress(); From 5be9bfa22e5e34067435c34feeb4c6720682d851 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Wed, 6 Dec 2023 11:47:10 +0900 Subject: [PATCH 3/4] fix: docs --- src/service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/service.ts b/src/service.ts index 6caae0b..88f5eff 100644 --- a/src/service.ts +++ b/src/service.ts @@ -10,12 +10,12 @@ export default class Service { } /** - * Check if service is running. It throws error when service is not running. + * Gets whether the service is running or not. + * @returns {Promise} */ async isRunning() { return await this.serviceController.isRunning(this.serviceName); } - /** * Get service information. not implemented yet. * @returns {string} Service information. From dabebdfc677433cf9af184e5249cd6a246454743 Mon Sep 17 00:00:00 2001 From: Yoojin Ko Date: Wed, 6 Dec 2023 11:49:18 +0900 Subject: [PATCH 4/4] style: space --- src/service.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/service.ts b/src/service.ts index 88f5eff..3a21d6e 100644 --- a/src/service.ts +++ b/src/service.ts @@ -16,6 +16,7 @@ export default class Service { async isRunning() { return await this.serviceController.isRunning(this.serviceName); } + /** * Get service information. not implemented yet. * @returns {string} Service information.