Documentation ¶
Index ¶
- Constants
- Variables
- func ContainsPaidTables(tables schema.Tables) bool
- func MakeAllTablesPaid(tables schema.Tables) schema.Tables
- func ValidateLicense(logger zerolog.Logger, meta plugin.Meta, licenseFileOrDirectory string) error
- func WithCancelOnQuotaExceeded(ctx context.Context, qm QuotaMonitor, ops ...QuotaCheckOption) (context.Context, error)
- type BatchUpdater
- type ErrNoQuota
- type License
- type LicenseWrapper
- type NoOpUsageClient
- type QuotaCheckOption
- type QuotaMonitor
- type TokenClient
- type UsageClient
- type UsageClientOptions
- func WithAPIClient(apiClient *cqapi.ClientWithResponses) UsageClientOptions
- func WithBatchLimit(batchLimit uint32) UsageClientOptions
- func WithLogger(logger zerolog.Logger) UsageClientOptions
- func WithMaxRetries(maxRetries int) UsageClientOptions
- func WithMaxTimeBetweenFlushes(maxTimeBetweenFlushes time.Duration) UsageClientOptions
- func WithMaxWaitTime(maxWaitTime time.Duration) UsageClientOptions
- func WithMinTimeBetweenFlushes(minTimeBetweenFlushes time.Duration) UsageClientOptions
- func WithURL(url string) UsageClientOptions
Constants ¶
const DefaultMaxQuotaFailures = 10 // 5 minutes
const DefaultQuotaCheckInterval = 30 * time.Second
Variables ¶
Functions ¶
func ContainsPaidTables ¶
ContainsPaidTables returns true if any of the tables are paid
func MakeAllTablesPaid ¶
MakeAllTablesPaid sets all tables to paid (including relations)
func ValidateLicense ¶ added in v4.24.0
func WithCancelOnQuotaExceeded ¶
func WithCancelOnQuotaExceeded(ctx context.Context, qm QuotaMonitor, ops ...QuotaCheckOption) (context.Context, error)
WithCancelOnQuotaExceeded monitors the quota usage at intervals defined by duration and cancels the context if the quota is exceeded
Types ¶
type BatchUpdater ¶
type BatchUpdater struct {
// contains filtered or unexported fields
}
func (*BatchUpdater) Close ¶
func (u *BatchUpdater) Close() error
func (*BatchUpdater) Increase ¶
func (u *BatchUpdater) Increase(rows uint32) error
func (*BatchUpdater) TeamName ¶ added in v4.21.1
func (u *BatchUpdater) TeamName() string
type ErrNoQuota ¶
type ErrNoQuota struct {
// contains filtered or unexported fields
}
func (ErrNoQuota) Error ¶ added in v4.21.1
func (e ErrNoQuota) Error() string
type License ¶ added in v4.24.0
type License struct { LicensedTo string `json:"licensed_to"` // Customers name, e.g. "Acme Inc" Plugins []string `json:"plugins,omitempty"` // List of plugins, each in the format <org>/<kind>/<name>, e.g. "cloudquery/source/aws". Optional, if empty all plugins are allowed. IssuedAt time.Time `json:"issued_at"` ValidFrom time.Time `json:"valid_from"` ExpiresAt time.Time `json:"expires_at"` }
func UnpackLicense ¶ added in v4.24.0
type LicenseWrapper ¶ added in v4.24.0
type NoOpUsageClient ¶ added in v4.24.0
type NoOpUsageClient struct {
TeamNameValue string
}
func (NoOpUsageClient) Close ¶ added in v4.24.0
func (NoOpUsageClient) Close() error
func (NoOpUsageClient) HasQuota ¶ added in v4.24.0
func (NoOpUsageClient) HasQuota(_ context.Context) (bool, error)
func (NoOpUsageClient) Increase ¶ added in v4.24.0
func (NoOpUsageClient) Increase(_ uint32) error
func (*NoOpUsageClient) TeamName ¶ added in v4.24.0
func (n *NoOpUsageClient) TeamName() string
type QuotaCheckOption ¶
type QuotaCheckOption func(*quotaChecker)
func WithQuotaCheckPeriod ¶
func WithQuotaCheckPeriod(duration time.Duration) QuotaCheckOption
WithQuotaCheckPeriod controls the time interval between quota checks
func WithQuotaMaxConsecutiveFailures ¶
func WithQuotaMaxConsecutiveFailures(n int) QuotaCheckOption
WithQuotaMaxConsecutiveFailures controls the number of consecutive failed quota checks before the context is cancelled
type QuotaMonitor ¶
type TokenClient ¶ added in v4.19.1
type UsageClient ¶
type UsageClient interface { QuotaMonitor // Increase updates the usage by the given number of rows Increase(uint32) error // Close flushes any remaining rows and closes the quota service Close() error }
func NewUsageClient ¶
func NewUsageClient(meta plugin.Meta, ops ...UsageClientOptions) (UsageClient, error)
type UsageClientOptions ¶
type UsageClientOptions func(updater *BatchUpdater)
func WithAPIClient ¶
func WithAPIClient(apiClient *cqapi.ClientWithResponses) UsageClientOptions
WithAPIClient sets the API client to use - defaults to a client using a bearer token generated from the refresh token stored in the configuration
func WithBatchLimit ¶
func WithBatchLimit(batchLimit uint32) UsageClientOptions
WithBatchLimit sets the maximum number of rows to update in a single request
func WithLogger ¶
func WithLogger(logger zerolog.Logger) UsageClientOptions
WithLogger sets the logger to use - defaults to a no-op logger
func WithMaxRetries ¶
func WithMaxRetries(maxRetries int) UsageClientOptions
WithMaxRetries sets the maximum number of retries to update the usage in case of an API error
func WithMaxTimeBetweenFlushes ¶
func WithMaxTimeBetweenFlushes(maxTimeBetweenFlushes time.Duration) UsageClientOptions
WithMaxTimeBetweenFlushes sets the flush duration - the time at which an update will be triggered even if the batch limit is not reached
func WithMaxWaitTime ¶
func WithMaxWaitTime(maxWaitTime time.Duration) UsageClientOptions
WithMaxWaitTime sets the maximum time to wait before retrying a failed update
func WithMinTimeBetweenFlushes ¶
func WithMinTimeBetweenFlushes(minTimeBetweenFlushes time.Duration) UsageClientOptions
WithMinTimeBetweenFlushes sets the minimum time between updates
func WithURL ¶
func WithURL(url string) UsageClientOptions
WithURL sets the API URL to use - defaults to https://api.cloudquery.io