Documentation
¶
Index ¶
- Constants
- type BillingOwner
- type DLQEntry
- type OwnerType
- type QuotaStatus
- type Service
- func (s *Service) CheckQuota(ctx context.Context, owner BillingOwner, eventType string) (bool, int64, error)
- func (s *Service) ExportUsage(ctx context.Context) (int, error)
- func (s *Service) GetQuotaStatus(ctx context.Context, owner BillingOwner) ([]QuotaStatus, error)
- func (s *Service) GetUsage(ctx context.Context, owner BillingOwner, from, to time.Time) (*UsageReport, error)
- func (s *Service) GetUsageByWorkspace(ctx context.Context, owner BillingOwner, workspaceID string, ...) (*UsageReport, error)
- func (s *Service) Record(event UsageEvent)
- func (s *Service) RecordLifecycleEvent(ctx context.Context, workspaceID, ownerID string, ownerType OwnerType, ...) error
- func (s *Service) SetActivePhasesChecker(fn WorkspacePhaseChecker)
- func (s *Service) SetBillingProvider(p WorkspaceBillingProvider)
- func (s *Service) SetDatabaseService(dbSvc interfaces.DatabaseService)
- func (s *Service) SetUsageReporter(r UsageReporter)
- func (s *Service) Start() error
- func (s *Service) Stop() error
- type UsageEvent
- type UsageReport
- type UsageReporter
- type WorkspaceBillingProvider
- type WorkspaceLifecycleEvent
- type WorkspacePhaseChecker
Constants ¶
View Source
const ( OwnerTypeUser = types.OwnerTypeUser OwnerTypeOrg = types.OwnerTypeOrg )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BillingOwner ¶
type BillingOwner = types.BillingOwner
type QuotaStatus ¶
type QuotaStatus = types.QuotaStatus
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func New ¶
func New(cfg *config.Config, log pkginterfaces.LoggerInterface, db *sql.DB) (*Service, error)
func (*Service) CheckQuota ¶
func (*Service) GetQuotaStatus ¶
func (s *Service) GetQuotaStatus(ctx context.Context, owner BillingOwner) ([]QuotaStatus, error)
func (*Service) GetUsage ¶
func (s *Service) GetUsage(ctx context.Context, owner BillingOwner, from, to time.Time) (*UsageReport, error)
func (*Service) GetUsageByWorkspace ¶
func (s *Service) GetUsageByWorkspace(ctx context.Context, owner BillingOwner, workspaceID string, from, to time.Time) (*UsageReport, error)
func (*Service) Record ¶
func (s *Service) Record(event UsageEvent)
func (*Service) RecordLifecycleEvent ¶
func (*Service) SetActivePhasesChecker ¶
func (s *Service) SetActivePhasesChecker(fn WorkspacePhaseChecker)
func (*Service) SetBillingProvider ¶
func (s *Service) SetBillingProvider(p WorkspaceBillingProvider)
func (*Service) SetDatabaseService ¶
func (s *Service) SetDatabaseService(dbSvc interfaces.DatabaseService)
func (*Service) SetUsageReporter ¶
func (s *Service) SetUsageReporter(r UsageReporter)
type UsageEvent ¶
type UsageEvent = types.UsageEvent
type UsageReport ¶
type UsageReport = types.UsageReport
type UsageReporter ¶
type UsageReporter interface {
ReportUsage(ctx context.Context, events []billing.UsageExportEvent) ([]int64, error)
}
UsageReporter reports metered usage to an external billing provider (e.g. Stripe). nil means usage is not reported externally (dev/noop mode).
type WorkspaceBillingProvider ¶
type WorkspaceBillingProvider interface {
ListAllWorkspacesForBilling(ctx context.Context) ([]database.WorkspaceBillingRecord, error)
}
type WorkspaceLifecycleEvent ¶
type WorkspacePhaseChecker ¶
Click to show internal directories.
Click to hide internal directories.