const rateLimiter = yield* $(
RateLimiter.make({ limit: 1000, interval: '20 seconds' })
)
// Query API costs 1 credit per call ( 1 is the default cost )
const queryAPIRL = compose(rateLimiter, RateLimiter.withCost(900))
// Mutation API costs 5 credits per call
const mutationAPIRL = compose(rateLimiter, RateLimiter.withCost(50))
// Use the pre-defined rate limiters
yield* $(queryAPIRL(Effect.log('Sample Query')))
yield* $(mutationAPIRL(Effect.log('Sample Mutation')))
// Or set a cost on-the-fly
yield* $(
rateLimiter(Effect.log('Another query with a different cost')).pipe(
RateLimiter.withCost(60)
)
)
const rateLimiter = yield* $(
RateLimiter.make({ limit: 1000, interval: '20 seconds' })
)
// Query API costs 1 credit per call ( 1 is the default cost )
const queryAPIRL = compose(rateLimiter, RateLimiter.withCost(900))
// Mutation API costs 5 credits per call
const mutationAPIRL = compose(rateLimiter, RateLimiter.withCost(50))
// Use the pre-defined rate limiters
yield* $(queryAPIRL(Effect.log('Sample Query')))
yield* $(mutationAPIRL(Effect.log('Sample Mutation')))
// Or set a cost on-the-fly
yield* $(
rateLimiter(Effect.log('Another query with a different cost')).pipe(
RateLimiter.withCost(60)
)
)