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

Function retryUpdate

packages/effect/src/internal/layer.ts:907–932  ·  view source on GitHub ↗
(
  schedule: Schedule.Schedule<X, E, RIn>,
  stateTag: Context.Tag<{ state: unknown }, { state: unknown }>,
  error: E,
  state: unknown
)

Source from the content-addressed store, hash-verified

905}
906
907const retryUpdate = <X, E, RIn>(
908 schedule: Schedule.Schedule<X, E, RIn>,
909 stateTag: Context.Tag<{ state: unknown }, { state: unknown }>,
910 error: E,
911 state: unknown
912): Layer.Layer<{ state: unknown }, E, RIn> => {
913 return fromEffect(
914 stateTag,
915 pipe(
916 Clock.currentTimeMillis,
917 core.flatMap((now) =>
918 pipe(
919 schedule.step(now, error, state),
920 core.flatMap(([state, _, decision]) =>
921 ScheduleDecision.isDone(decision) ?
922 core.fail(error) :
923 pipe(
924 Clock.sleep(Duration.millis(Intervals.start(decision.intervals) - now)),
925 core.as({ state })
926 )
927 )
928 )
929 )
930 )
931 )
932}
933
934/** @internal */
935export const scoped = dual<

Callers 1

retryLoopFunction · 0.85

Calls 6

startMethod · 0.80
fromEffectFunction · 0.70
pipeFunction · 0.70
stepMethod · 0.65
failMethod · 0.65
sleepMethod · 0.65

Tested by

no test coverage detected