Skip to content

Conversation

@mnorbury
Copy link
Contributor

This adds a background monitoring process that will periodically check the remaining quota for a premium plugin. If the quota is exceeded then a context cancellation is triggered, forcing the sync process to stop.

fixes: https://github.com/cloudquery/cloudquery-issues/issues/749

This adds a background monitoring process that will periodically check the remaining quota for a premium plugin. If the quota is exceeded then a context cancellation is triggered, forcing the sync process to stop.

fixes: cloudquery/cloudquery-issues#749
@github-actions
Copy link

github-actions bot commented Oct 27, 2023

⏱️ Benchmark results

  • Glob-8 ns/op: 194.6


ctx, cancel := m.startQuotaMonitor(ctx)

return ctx, cancel, nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me like we don't need to return cancel as part of the function signature here, as the cancellation is handled internally

Comment on lines 70 to 72
if err != nil {
continue
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to set some limit on how long the sync can continue without knowing the remaining quota.

premium/usage.go Outdated
}

// WithTeamName sets the team name to use - defaults to the team name from the configuration
func WithTeamName(teamName cqapi.TeamName) UsageClientOptions {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should keep this private and use it only for testing, I don't see why plugin authors would need to set this right now

@kodiakhq kodiakhq bot merged commit b7a2ca5 into main Oct 30, 2023
@kodiakhq kodiakhq bot deleted the feat/add-quota-monitoring branch October 30, 2023 16:17
hermanschaaf pushed a commit that referenced this pull request Oct 30, 2023
🤖 I have created a release *beep* *boop*
---


##
[4.17.0](v4.16.1...v4.17.0)
(2023-10-30)


### Features

* Add IsPaid flag to table definition
([#1327](#1327))
([ffd14bf](ffd14bf))
* Add OnBeforeSend hook
([#1325](#1325))
([023ebbc](023ebbc))
* Adding a batch updater to allow usage updates to be batched
([#1326](#1326))
([0301ed7](0301ed7))
* Adding quota monitoring for premium plugins
([#1333](#1333))
([b7a2ca5](b7a2ca5))
* Allow sync to be cancelled when in progress
([#1334](#1334))
([6d7be0b](6d7be0b))


### Bug Fixes

* **deps:** Update github.com/cloudquery/arrow/go/v14 digest to 50d3871
([#1337](#1337))
([f15a89d](f15a89d))
* **deps:** Update github.com/cloudquery/arrow/go/v14 digest to f46436f
([#1329](#1329))
([ee24384](ee24384))
* **deps:** Update module github.com/cloudquery/cloudquery-api-go to
v1.4.2 ([#1335](#1335))
([2ecd2a1](2ecd2a1))
* **deps:** Update module github.com/cloudquery/plugin-pb-go to v1.13.0
([#1332](#1332))
([5553f85](5553f85))
* **deps:** Update module github.com/cloudquery/plugin-pb-go to v1.13.1
([#1336](#1336))
([b782ee7](b782ee7))
* **deps:** Update module google.golang.org/grpc to v1.58.3 [SECURITY]
([#1331](#1331))
([43f60c2](43f60c2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants