-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monitoring
: add service URL manager
#3134
Conversation
- sendGetRequest to sendRequest and use fetch instead of axios. - replace serviceUrl and serviceName with getters - add update method that uses URL setter - Make all IServiceBase classes take an optional options on their contractor, add error handling for side effect - Grouped all RMB properties to RMB to RMBProps - Feat: - add stats monitor class that monitors stats service - add activation monitor class that monitor activation service
it is class managing service URLs with liveness checking <pick the first reachable endpoint for each service> - Define retries and silent mode settings - Implement constructor to handle StackManagerOptions - Add private handleErrorsOnSilentMode method for error handling based on silent mode - Implement getAvailableStack method to find reachable service URL - Implement getAvailableServicesStack method to fetch and store available service URLs for all services
…urn undefined or emptystring remove debug lines
…into development_monitoring__stacks
* Updates the service with the provided parameters. | ||
* @param {P} param - The parameter object with specific keys, should be specified on class. | ||
*/ | ||
disconnect: () => Promise<void>; | ||
update(param: P): void; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we still need this update method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I should replace it with normal setter, and use it here, with the reachable url
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, Omar
export class GridProxyMonitor implements ILivenessChecker { | ||
private readonly name = "GridProxy"; | ||
private url: string; | ||
constructor(gridProxyUrl: string) { | ||
this.url = gridProxyUrl; | ||
private readonly _name = "GridProxy"; | ||
private _url: string; | ||
constructor(gridProxyUrl?: string) { | ||
if (gridProxyUrl) this.url = gridProxyUrl; | ||
} | ||
serviceName() { | ||
return this.name; | ||
public get name() { | ||
return this._name; | ||
} | ||
serviceUrl() { | ||
return this.url; | ||
public get url() { | ||
return this._url ?? ""; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that you have multiple classes that share a significant amount of similar functionality. To improve code maintainability and reduce duplication, I suggest creating a Base
class that encapsulates the common logic. Then, each of the existing classes can inherit from this Base
class, allowing them to share the common behavior while still implementing any specific functionality they need.
class Base {
get url(): string{}
set url(name: string){}
async isAlive(url: string): Promise<ServiceStatus> {}
....
}
class X extends Base {
ping(url: string){
...
}
}
class Y extends Base {
pong(){
...
}
}
try { | ||
const statusPromise = service.isAlive(url); | ||
|
||
const timeoutPromise = new Promise((resolve, reject) => { | ||
setTimeout(() => { | ||
reject(new Error("Timeout")); | ||
}, _timeout * 1000); | ||
}); | ||
|
||
const result = await Promise.race([statusPromise, timeoutPromise]); | ||
if (result instanceof Error && result.message === "Timeout") { | ||
throw result; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try { | |
const statusPromise = service.isAlive(url); | |
const timeoutPromise = new Promise((resolve, reject) => { | |
setTimeout(() => { | |
reject(new Error("Timeout")); | |
}, _timeout * 1000); | |
}); | |
const result = await Promise.race([statusPromise, timeoutPromise]); | |
if (result instanceof Error && result.message === "Timeout") { | |
throw result; | |
} | |
const TIME_OUT = "Timeout"; | |
try { | |
const statusPromise = service.isAlive(url); | |
const timeoutPromise = new Promise((resolve, reject) => { | |
setTimeout(() => { | |
reject(new Error(TIME_OUT)); | |
}, _timeout * 1000); | |
}); | |
const result = await Promise.race([statusPromise, timeoutPromise]); | |
if (result instanceof Error && result.message === TIME_OUT) { | |
throw result; | |
} |
Updated
Description
ServiceURLManager
: a class managing service URLs with liveness checkingpick the first reachable endpoint for each service
Changes
Refactor:
RMB
andTFChain
ping with http using health endpoints,sendGetRequest
tosendRequest
isAlive
logicIServiceBase
classes take an optional options on their contractor, add error handling for side effectRMBProps
isAlive
Feat:
serviceURLManager
URLManagerOptions
handleErrorsOnSilentMode
method for error handling based on silent modegetAvailableStack
method to find reachable service URLgetAvailableServicesStack
method to fetch and store available service URLs for all servicesExamples: update service monitor example and add
serviceURlManager
Example, also update example command to take the example file pathFix: main and type paths in package.json
Related Issues
sdk-ts
: Support multiple stacks per network #3078Documentation PR
For UI changes, Please provide the Documetation PR on info_grid
Checklist