Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion packages/effect-app/src/client/apiClientFactory.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Rpc, RpcClient, RpcGroup, RpcSerialization } from "@effect/rpc"
import { Schedule } from "effect"
import * as Config from "effect/Config"
import { flow } from "effect/Function"
import * as HashMap from "effect/HashMap"
Expand Down Expand Up @@ -49,6 +50,7 @@ export const HttpClientLayer = (config: ApiConfig) =>
Effect
.gen(function*() {
const baseClient = yield* HttpClient.HttpClient
// const devMode = yield* DevMode
const client = baseClient.pipe(
HttpClient.mapRequest(HttpClientRequest.prependUrl(config.url + "/rpc")),
HttpClient.mapRequest(
Expand All @@ -63,7 +65,24 @@ export const HttpClientLayer = (config: ApiConfig) =>
)(req)
)
)
)
),
// TODO: should we enable this?
// it would increase local e2e test time too
// perhaps it's better to teach developers to use "slow browser" throttling instead
// or we should be able to skip in on e2e requests?
// HttpClient.transformResponse(
// Effect.fnUntraced(function*(response) {
// if (devMode) {
// const sleepFor = yield* Random.nextRange(200, 500)
// yield* Effect.sleep(Duration.millis(sleepFor))
// }
// return yield* response
// })
// ),
HttpClient.retryTransient({
times: 3,
schedule: Schedule.exponential("100 millis")
})
)
return client
})
Expand Down