Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ProgressiveBilling) - add Clock::RefreshLifetimeUsagesJob + LifetimeUsages::RecalculateAndCheckService #2435

Merged
merged 8 commits into from
Aug 20, 2024

Conversation

nudded
Copy link
Contributor

@nudded nudded commented Aug 19, 2024

Context

AI companies want their users to pay before the end of a period if usage skyrockets. The problem being that self-serve companies can overuse their API without paying, triggering lots of costs on their side.

Description

Adds:

  • Clock::RefreshLifetimeUsagesJob
    • fetches all usages to recalculate and enqueues the RefreshJob
  • LifetimeUsages::RecalculateAndCheckJob
    • calls the RecalculateAndCheckService for this lifetime_usage, guarantees only 1 running at a time.
  • LifetimeUsages::RecalculateAndCheckService
    • recalculates the usage
    • checks if there are thresholds that have been passed
    • send webhooks if needed
    • creates an invoice if needed

@nudded nudded force-pushed the feat-prog-billing-refresh-usage-clock branch from 972a449 to ee1ed98 Compare August 19, 2024 14:28
@nudded nudded marked this pull request as ready for review August 19, 2024 14:38
@nudded nudded force-pushed the feat-prog-billing-refresh-usage-clock branch 2 times, most recently from ef38122 to e391d9a Compare August 19, 2024 14:41
@nudded nudded force-pushed the feat-prog-billing-refresh-usage-clock branch from 657cc09 to 95dc5fa Compare August 20, 2024 07:26
@nudded nudded merged commit 79ce6ef into main Aug 20, 2024
6 checks passed
@nudded nudded deleted the feat-prog-billing-refresh-usage-clock branch August 20, 2024 07:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants