| 1 | import * as Effect from "effect/Effect"; |
| 2 | |
| 3 | import { environmentEndpointUrl } from "./endpoint.ts"; |
| 4 | import { executeEnvironmentHttpRequest, makeEnvironmentHttpApiGroupClient } from "../rpc/http.ts"; |
| 5 | |
| 6 | const DEFAULT_REMOTE_REQUEST_TIMEOUT_MS = 10_000; |
| 7 | |
| 8 | export const fetchRemoteEnvironmentDescriptor = Effect.fn( |
| 9 | "clientRuntime.environment.fetchRemoteEnvironmentDescriptor", |
| 10 | )(function* (input: { readonly httpBaseUrl: string; readonly timeoutMs?: number }) { |
| 11 | const client = yield* makeEnvironmentHttpApiGroupClient(input.httpBaseUrl, "metadata"); |
| 12 | return yield* executeEnvironmentHttpRequest( |
| 13 | environmentEndpointUrl(input.httpBaseUrl, "/.well-known/t3/environment"), |
| 14 | input.timeoutMs ?? DEFAULT_REMOTE_REQUEST_TIMEOUT_MS, |
| 15 | client.descriptor(), |
| 16 | ); |
| 17 | }); |