get-convex / get-convex/rate-limiter
Request: exposing token utilization, getValue
- Dominant language
- TypeScript
- Stars
- 27
- Forks
- 8
- Avg merge
- 8d 5h
- Merged PRs (30d)
- 11
Description
This is a following conversation in the beta components thread.
Context: Currently the api only provides you the next time that you can retry at. We reverse engineered the convex helper rate limiter to show a user their personal bucket status for that user account. Within this usecase sharding is not necessary avoiding the need to query a sample set. But I could see the use of that with a bigger token bucket with more resolution and activity.
Ian suggested:
```
const value = await rateLimiter.getValue(ctx, "myLimit");
// to just sample a few shards for efficiency / avoiding OCCs
const value = await rateLimiter.getValue(ctx, "myLimit", { sampleShards: 3 });
```
This works for us. But may have limited use for other users who don't want to reverse engineer it.
I think it would be nice to have it optionally available when you call rateLimiter.check
Contributor guide
Assessment
This issue has not been assessed yet.