MCPcopy Create free account
hub / github.com/Effect-TS/effect / fromRetryOptions

Function fromRetryOptions

packages/effect/src/internal/schedule.ts:2025–2048  ·  view source on GitHub ↗
(options: Effect.Retry.Options<any>)

Source from the content-addressed store, hash-verified

2023
2024/** @internal */
2025export const fromRetryOptions = (options: Effect.Retry.Options<any>): Schedule.Schedule<any, any, any> => {
2026 const base = options.schedule ?? forever
2027 const withWhile = options.while ?
2028 whileInputEffect(base, (e) => {
2029 const applied = options.while!(e)
2030 if (typeof applied === "boolean") {
2031 return core.succeed(applied)
2032 }
2033 return scheduleDefectWrap(applied)
2034 }) :
2035 base
2036 const withUntil = options.until ?
2037 untilInputEffect(withWhile, (e) => {
2038 const applied = options.until!(e)
2039 if (typeof applied === "boolean") {
2040 return core.succeed(applied)
2041 }
2042 return scheduleDefectWrap(applied)
2043 }) :
2044 withWhile
2045 return options.times !== undefined ?
2046 intersect(withUntil, recurs(options.times)) :
2047 withUntil
2048}
2049
2050/** @internal */
2051export const retryOrElse_Effect = dual<

Callers 1

schedule.tsFile · 0.85

Calls 2

scheduleDefectWrapFunction · 0.85
recursFunction · 0.85

Tested by

no test coverage detected