trial

package
v1.20.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package trial grants the registration trial subscription. It consumes the identity.user_registered event: the grant runs in a subscription-domain transaction, idempotent via the inbox marker, serialized per user by the subscription serial lock. Only the module facade may reach it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Deps

type Deps struct {
	Plans repository.SubscribeRepo
	Cache repository.UserCacheRepo
	Store repository.Store
	// TrialPolicy snapshots the runtime-mutable trial settings per call.
	TrialPolicy func() Policy
}

Deps declares the subdomain's dependencies; the module facade forwards them from the composition root.

type Policy

type Policy struct {
	Enabled  bool
	PlanID   int64
	Duration int64
	TimeUnit string
}

Policy is the per-call view of the runtime-mutable trial settings.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service is the trial-grant entry point used by the subscription facade.

func NewService

func NewService(deps Deps) *Service

func (*Service) GrantTrial

func (s *Service) GrantTrial(ctx context.Context, userID int64) error

GrantTrial applies the registration trial exactly once for the user. A disabled trial still consumes the event (the marker records the decision), so a later policy change never retroactively grants trials to old registrations — matching the old in-transaction behavior where the policy was evaluated at registration time.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL