-
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
sdk-ts
: Support multiple stacks per network
#3078
Comments
also current mentor services logs the aliveness of the services but do not return any values,i think it need some refactor adding new methods |
WIP: creating the logic to pick the first available stack per service add this init class to the export class serviceStackPicker {
private result: ServicesUrls = {};
constructor(public options: StackPickerOptions) {}
private async pingService(service: ILivenessChecker) {
const status = await service.isAlive();
if ("disconnect" in service) {
await (service as IDisconnectHandler).disconnect();
}
return status;
}
async GetAvailableServices(): Promise<ServicesUrls> {
if ("tfChain" in this.options)
this.result.tfChain = await this.getAvailableServiceStack(
this.options.tfChain.slice(1),
new TFChainMonitor(this.options.tfChain[0]),
);
if ("gridProxy" in this.options)
this.result.GirdProxy = await this.getAvailableServiceStack(
this.options.GirdProxy.slice(1),
new GridProxyMonitor(this.options.GirdProxy[0]),
);
return this.result;
}
async getAvailableServiceStack(urls: string[], service: ILivenessChecker) {
let index = 0;
do {
const status = await this.pingService(service);
if (status.alive) return service.serviceUrl();
console.log(`${service.serviceName()}: failed to ping ${service.serviceUrl()}, due to ${status.error}`);
service.setServiceURl(urls[index++]);
} while (index < urls.length);
}
} and should be called anywhere with const test = new serviceStackPicker({
tfChain: ["faf", "wss://tfchain.dev.grid.tf/ws", "wsss://tfchain.dev.grid.tf/ws"],
GirdProxy: ["hahah", "https://gridproxy.dev.grid.tf"],
});
console.log(await test.GetAvailableServices()); also we had to add this snips is the initial phase of coding, feel free to suggest any refactors |
Issue Update: |
it shouldn't be interactive. you can export them with comma-separate then split them in the script |
Issue update:
|
Issue update: |
Issue update: applied pr comments and introduce new features |
New monitoring pr is ready : #3134 |
All review comments applied on #3134 |
Issue update: Blocker: tfgrid-sdk-ts/packages/playground/src/clients/index.ts Lines 1 to 10 in 0a5568e
those clients got loaded before initializing the envs and got undifined urls, suggest moving those clients to grid store |
all requested changes applied, and ui is ready as well. |
As we discussed with @sameh-farouk, we can use chain |
Issue update
Blocker |
Issue update: but if we remove one of the invalid/unreachable urls from the array it works fine.
details of the new applied mechanism:
Concerns: |
Issue update : |
I faced an issue while testing playground integration: |
work completed:
|
Verified, Devnet. The stack is working fine, checking all the URLs at once with 3 retries and picking the working one in the same order as they were written. For one failing but the other working. Created an issue for the Grid Client to work as config in playground: #3399. New test Case: TC2825 - Run locally with multiple stack |
verified changed the stacks in the file of tfgrid-sdk-ts/packages/playground/public/config.js and also tried to implement wrong urls in the file to check the behaviour |
threefoldtech/home#1550
The text was updated successfully, but these errors were encountered: