MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / fetchEnvironmentsWithHealth

Function fetchEnvironmentsWithHealth

console/src/store/environments.ts:157–276  ·  view source on GitHub ↗
({
  cloudRegions,
  appConfig,
}: {
  cloudRegions: Map<string, CloudRegion>;
  appConfig: AppConfig;
})

Source from the content-addressed store, hash-verified

155);
156
157export const fetchEnvironmentsWithHealth = async ({
158 cloudRegions,
159 appConfig,
160}: {
161 cloudRegions: Map<string, CloudRegion>;
162 appConfig: AppConfig;
163}) => {
164 const result = new Map<string, Environment>();
165
166 if (appConfig.mode === "self-managed") {
167 const status = await fetchEnvironmentHealth({
168 httpAddress: appConfig.environmentdConfig.environmentdHttpAddress,
169 resolvable: true,
170 enabledAt: fakeEnabledAt.toString(),
171 });
172 result.set(
173 appConfig.environmentdConfig.regionId,
174 buildFakeEnabledEnvironment({
175 httpAddress: appConfig.environmentdConfig.environmentdHttpAddress,
176 status,
177 }),
178 );
179 return result;
180 }
181
182 if (appConfig.environmentdConfigOverride) {
183 const status = await fetchEnvironmentHealth({
184 httpAddress: appConfig.environmentdConfigOverride.environmentdHttpAddress,
185 resolvable: true,
186 enabledAt: fakeEnabledAt.toString(),
187 });
188 result.set(
189 appConfig.environmentdConfigOverride.regionId,
190 buildFakeEnabledEnvironment({
191 httpAddress:
192 appConfig.environmentdConfigOverride.environmentdHttpAddress,
193 status,
194 }),
195 );
196 return result;
197 }
198
199 for (const region of cloudRegions.values()) {
200 const regionId = getRegionId(region);
201 await Sentry.startSpan(
202 {
203 name: "fetch-environment-health",
204 op: "http.client",
205 attributes: { region: regionId },
206 },
207 async () => {
208 try {
209 const { data: regionResult } = await getRegion(region.regionApiUrl);
210 const regionInfo =
211 "regionInfo" in regionResult && regionResult.regionInfo;
212 const regionState =
213 "regionState" in regionResult && regionResult.regionState;
214 if (regionState === "enablement-pending") {

Callers 1

usePollEnvironmentHealthFunction · 0.85

Calls 8

getRegionIdFunction · 0.90
getRegionFunction · 0.90
isApiErrorFunction · 0.90
fetchEnvironmentHealthFunction · 0.85
setMethod · 0.45
valuesMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected