-
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
Support multiple stacks per network in gird client #3200
Support multiple stacks per network in gird client #3200
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
…nect and disconnect
…into development_monitoring__stacks
…tech/tfgrid-sdk-ts into development_monitoring__stacks_gridclient
packages/grid_client/src/client.ts
Outdated
async setServiceURLs(): Promise<void> { | ||
await getAvailableURLs(this.clientOptions); | ||
} |
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.
what is the added value of this method?
…into development_monitoring__stacks_gridclient
*/ | ||
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)); | ||
} |
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 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
…into development_monitoring__stacks_gridclient
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 serviceif it is not provided
Related Issues
sdk-ts
: Support multiple stacks per network #3078Documentation PR
For UI changes, Please provide the Documetation PR on info_grid
Checklist