MCPcopy Create free account
hub / github.com/effect-app/libs / SEM_withPermitsDuration

Function SEM_withPermitsDuration

packages/infra/src/rateLimit.ts:37–51  ·  view source on GitHub ↗
(permits: number, duration: Duration.Duration)

Source from the content-addressed store, hash-verified

35 * failure, or interruption.
36 */
37export function SEM_withPermitsDuration(permits: number, duration: Duration.Duration) {
38 return (self: Semaphore): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R> => {
39 return <A, E, R>(effect: Effect.Effect<A, E, R>) =>
40 Effect.uninterruptibleMask(
41 (restore) =>
42 restore(self.take(permits))
43 .pipe(Effect.andThen(
44 restore(effect)
45 .pipe(Effect.ensuring(
46 Effect.delay(self.release(permits), duration)
47 ))
48 ))
49 )
50 }
51}
52
53export interface BatchOptions {
54 readonly concurrency?: Concurrency | undefined

Callers

nothing calls this directly

Calls 3

pipeMethod · 0.65
takeMethod · 0.65
releaseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…