Help us shape the future of Go! Take the 2026 Go Developer Survey

entitlement

package
v1.21.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package entitlement stores provider-authoritative subscription periods.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Period

type Period struct {
	ID              string `gorm:"primaryKey;type:char(64)"`
	EntitlementID   string `gorm:"type:char(64);not null;index"`
	TransactionKey  string `gorm:"type:varchar(255);not null"`
	UserSubscribeID int64  `gorm:"not null;index"`
	OrderID         int64  `gorm:"not null"`
	PlanID          int64  `gorm:"not null"`
	// Empty for local orders; month or year for Apple auto-renewable products.
	BillingInterval string    `gorm:"type:varchar(16);not null;default:''"`
	TrafficLimit    int64     `gorm:"not null"`
	StartAt         time.Time `gorm:"not null"`
	EndAt           time.Time `gorm:"not null"`
	TrafficReset    bool      `gorm:"not null"`
	CreatedAt       time.Time
	UpdatedAt       time.Time
}

Period records an absolute interval rather than an increment to replay. Its global provider transaction identity prevents cross-account reuse.

func (Period) TableName

func (Period) TableName() string

type Revision

type Revision struct {
	ID            string `gorm:"primaryKey;type:varchar(96)"`
	EntitlementID string `gorm:"type:char(64);not null;index"`
	Payload       string `gorm:"type:text;not null"`
	CreatedAt     time.Time
}

Revision preserves reconciled changes, including revocations and reversals. Unlike the operational inbox, this history is not subject to short retention.

func (Revision) TableName

func (Revision) TableName() string

type State

type State struct {
	ID              string `gorm:"primaryKey;type:char(64)"`
	Source          string `gorm:"type:varchar(32);not null"`
	Scope           string `gorm:"type:varchar(255);not null"`
	SubscriptionKey string `gorm:"type:varchar(255);not null"`
	UserID          int64  `gorm:"not null"`
	UserSubscribeID int64  `gorm:"not null;uniqueIndex"`
	Revision        int64  `gorm:"not null"`
	Fingerprint     string `gorm:"type:char(64);not null"`
	PeriodID        string `gorm:"type:char(64);not null"`
	Mode            string `gorm:"type:varchar(32);not null"`
	Status          string `gorm:"type:varchar(32);not null"`
	AutoRenew       bool   `gorm:"not null"`
	GraceUntil      *time.Time
	RevokedAt       *time.Time
	UpdatedAt       time.Time
}

State is the last reconciled snapshot for one provider subscription. Revision is allocated by the verified billing ledger, never by notification arrival.

func (State) TableName

func (State) TableName() string

Jump to

Keyboard shortcuts

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