-
Notifications
You must be signed in to change notification settings - Fork 13
/
microserviceUserManager.ts
62 lines (51 loc) · 1.86 KB
/
microserviceUserManager.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright 2020-2020 The Mandarine.TS Framework authors. All rights reserved. MIT license.
import { Mandarine } from "../../Mandarine.ns.ts";
export class MicroserviceUserManager {
private getMicroserviceManager() {
return Mandarine.Global.getMicroserviceManager();
}
/**
* Gets the list of all the microservices present in the application.
*/
public getMicroservices() {
this.getMicroserviceManager().getMicroservices();
}
/**
*
* @param microservice to be checked
* @returns True if microservice is healthy or false if it is not
*/
public async checkHealth(microservice: Mandarine.MandarineCore.MicroserviceItem): Promise<boolean> {
return await this.getMicroserviceManager().isHealthyByMicroservice(microservice);
}
/**
*
* @param microservice to be deleted
*/
public delete(microservice: Mandarine.MandarineCore.MicroserviceItem) {
this.getMicroserviceManager().deleteByMicroservice(microservice);
}
/**
* Enable automatic health check.
* If enabled, Mandarine will check healthiness of microservices and remount them if they are unhealthy
*/
public enableAutomaticHealthCheck() {
this.getMicroserviceManager().enableAutomaticHealthInterval();
}
/**
* Disables automatic health checks.
* If disabled, Mandarine is not responsible for checking and remounting unhealthy microservices
*/
public disableAutomaticHealthCheck() {
this.getMicroserviceManager().disableAutomaticHealthInterval();
}
/**
*
* Generates a new microservice and initializes it.
*
* @param microservice to be remounted
*/
public remountFromExistent(microservice: Mandarine.MandarineCore.MicroserviceItem) {
this.getMicroserviceManager().remountFromExistent(microservice);
}
}