Documentation
¶
Index ¶
- type FreeService
- func (s *FreeService) CheckActive(_ context.Context, _ uuid.UUID) error
- func (s *FreeService) CheckFeature(_ context.Context, _ uuid.UUID, _ domain.SubscriptionFeature) error
- func (s *FreeService) CheckStorageQuota(_ context.Context, _ uuid.UUID) error
- func (s *FreeService) GetEffective(_ context.Context, userUuid uuid.UUID) (domain.EffectiveSubscription, error)
- func (s *FreeService) GetUsage(_ context.Context, _ uuid.UUID) (domain.StorageUsage, error)
- func (s *FreeService) HasFeature(_ context.Context, _ uuid.UUID, _ domain.SubscriptionFeature) (bool, error)
- type PaidService
- func (s *PaidService) CheckActive(ctx context.Context, userUuid uuid.UUID) error
- func (s *PaidService) CheckFeature(ctx context.Context, userUuid uuid.UUID, feature domain.SubscriptionFeature) error
- func (s *PaidService) CheckStorageQuota(ctx context.Context, userUuid uuid.UUID) error
- func (s *PaidService) GetEffective(ctx context.Context, userUuid uuid.UUID) (domain.EffectiveSubscription, error)
- func (s *PaidService) GetUsage(ctx context.Context, userUuid uuid.UUID) (domain.StorageUsage, error)
- func (s *PaidService) HasFeature(ctx context.Context, userUuid uuid.UUID, feature domain.SubscriptionFeature) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FreeService ¶
type FreeService struct{}
FreeService is used when config.EnvironmentConfig.SubscriptionsEnabled is false: every check always passes and quotas are unlimited, with no CouchDB/S3 calls made (GetUsage would be meaningless when nothing enforces it).
func NewFree ¶
func NewFree() *FreeService
func (*FreeService) CheckActive ¶
func (*FreeService) CheckFeature ¶
func (s *FreeService) CheckFeature(_ context.Context, _ uuid.UUID, _ domain.SubscriptionFeature) error
func (*FreeService) CheckStorageQuota ¶
func (*FreeService) GetEffective ¶
func (s *FreeService) GetEffective(_ context.Context, userUuid uuid.UUID) (domain.EffectiveSubscription, error)
func (*FreeService) GetUsage ¶
func (s *FreeService) GetUsage(_ context.Context, _ uuid.UUID) (domain.StorageUsage, error)
func (*FreeService) HasFeature ¶
func (s *FreeService) HasFeature(_ context.Context, _ uuid.UUID, _ domain.SubscriptionFeature) (bool, error)
type PaidService ¶
type PaidService struct {
// contains filtered or unexported fields
}
PaidService is used when config.EnvironmentConfig.SubscriptionsEnabled is true: it enforces each user's effective plan+overrides — feature gating (formerly UserPermissions) and storage quotas, measured on demand against CouchDB/S3 rather than a maintained running counter.
func NewPaid ¶
func NewPaid( subscriptions repository.Subscriptions, vaults repository.Vaults, couchInstances repository.CouchInstances, s3Instances repository.S3Instances, ) *PaidService
func (*PaidService) CheckActive ¶
func (*PaidService) CheckFeature ¶
func (s *PaidService) CheckFeature(ctx context.Context, userUuid uuid.UUID, feature domain.SubscriptionFeature) error
func (*PaidService) CheckStorageQuota ¶
CheckStorageQuota rejects once usage is already at or over quota — a coarse pre-write check (on-demand measurement, not byte-exact accounting for the write in flight).
func (*PaidService) GetEffective ¶
func (s *PaidService) GetEffective(ctx context.Context, userUuid uuid.UUID) (domain.EffectiveSubscription, error)
func (*PaidService) GetUsage ¶
func (s *PaidService) GetUsage(ctx context.Context, userUuid uuid.UUID) (domain.StorageUsage, error)
GetUsage sums CouchDB + S3 storage across every vault userUuid belongs to, measured live — no maintained running counter.
func (*PaidService) HasFeature ¶
func (s *PaidService) HasFeature( ctx context.Context, userUuid uuid.UUID, feature domain.SubscriptionFeature, ) (bool, error)