Skip to content
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

Support multiple stacks per network in gird client #3200

Merged
merged 50 commits into from
Aug 19, 2024

Conversation

0oM4R
Copy link
Contributor

@0oM4R 0oM4R commented Aug 1, 2024

Description

Using monitoring package, we are getting the available url for services if it is not provided in clien options

Changes

add setServiceURLs that is updating client options with available services urls for only the services that do not associated with url in client options.
this method is used in connect method and before getDefaultUrl to insure that we have the available stack url for each service if it is not provided

Related Issues

Documentation PR

For UI changes, Please provide the Documetation PR on info_grid

Checklist

  • Tests included
  • Build pass
  • Documentation
  • Code format and docstrings
  • Screenshots/Video attached (needed for UI changes)

0oM4R added 30 commits July 18, 2024 00:27
  - 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
- change naming
- remove error on get url and return empty string in case the url is not set yet
- add errror handling in isAlive, will throw in case the service url is not set
- rename constractor param
- use replace instade of split
Base automatically changed from development_monitoring__stacks to development August 11, 2024 11:02
0oM4R added 2 commits August 13, 2024 16:55
…tech/tfgrid-sdk-ts into development_monitoring__stacks_gridclient
Comment on lines 109 to 111
async setServiceURLs(): Promise<void> {
await getAvailableURLs(this.clientOptions);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the added value of this method?

@amiraabouhadid amiraabouhadid changed the title Support multiple stacks ber network in gird client Support multiple stacks per network in gird client Aug 18, 2024
Comment on lines 95 to 123
*/
export async function getAvailableURLs(clientOptions: ClientOptions) {
const { proxyURL, relayURL, substrateURL, graphqlURL, activationURL, network } = clientOptions;
const currentURLs = { proxyURL, relayURL, substrateURL, graphqlURL, activationURL };
const base = network === NetworkEnv.main ? "grid.tf" : `${network}.grid.tf`;
const URLS = {
relayURL: [`wss://relay.${base}`, `wss://relay.02.${base}`],
proxyURL: [`https://gridproxy.${base}`, `https://gridproxy.02.${base}`],
activationURL: [
`https://activation.${base}/activation/activate`,
`https://activation.02.${base}/activation/activate`,
],
graphqlURL: [`https://graphql.${base}/graphql`, `https://graphql.02.${base}/graphql`],
substrateURL: [`wss://tfchain.${base}/ws`, `wss://tfchain.02.${base}/ws`],
};
const missingServicesURLS = getServicesWithoutURLs(currentURLs);

if (missingServicesURLS.length == 0) return;

const services = missingServicesURLS.reduce((acc, servicesName) => {
acc.push(prepareServices(servicesName, URLS[servicesName]));
return acc;
}, [] as Service[]);
const result = await new ServiceUrlManager({
services: services,
silent: true,
}).getAvailableServicesStack();
Object.assign(clientOptions, mapResult(result, missingServicesURLS));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think mutating object byRef might lead to unexpected behaviour specially in vue apps as it turns objects into proxy which rerender ui whenever it gets mutated

So I think we should avoid update objects byref

0oM4R added 2 commits August 18, 2024 15:34
- make set serviceurls private
- remove mutating clientoptions by ref and return service urls, then update the clientOptions
- make serviceUrlManager work on default mode not silent to throw error
@0oM4R 0oM4R merged commit 03ea913 into development Aug 19, 2024
9 checks passed
@0oM4R 0oM4R deleted the development_monitoring__stacks_gridclient branch August 19, 2024 09:04
@xmonader xmonader added this to the 2.6.0 milestone Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants