MCPcopy Index your code
hub / github.com/Effect-TS/effect / retryUpdate

Function retryUpdate

packages/effect/src/internal/layer.ts:906–931  ·  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

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