feat: chron job to rate limit orgs based on usage
Problem
We want to check if orgs are above their usage limit, and add them to a list of rate limited organizations.
To be released together with https://github.com/PostHog/posthog/pull/13519
Changes
Add a chron job to check if organization's stored usage (saved after talking to the billing service), which is relevant up to the day before, plus today's unreported usage, is bigger than the billing limit. If yes, we add the org_id to a set in redis, one for event rate limiting, one for recordings rate limiting.
Small edge case: this won't fully work if in the future we'll want to rate limit orgs across different environments (EU + US), as the unreported usage will only be related to one instance, which means we might rate limit with a delay of one day in that case.
How did you test this code?
Added tests for the rate limiting task
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.
This PR was closed due to lack of activity. Feel free to reopen if it's still relevant.
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.