Media / foldkit-media/server

admissionRateLimiter

function · packages/media/src/server/admission.ts:28

function admissionRateLimiter(options: {
  readonly limit: number
  readonly window: Duration.Input
  readonly algorithm?: 'fixed-window' | 'token-bucket'
}): Layer.Layer<Admission, never, RateLimiter.RateLimiter>

Admission through Effect's RateLimiter, limit misses a client per window, over the limiter's store (RateLimiter.layerStoreMemory for one process, Redis for several). A store that fails admits the request, logged: a limiter that is down should not take the images down with it.