subscription

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Overview

Package subscription is the facade of the subscription module: plan and group management plus the public storefront listings (subscription delivery joins as migration proceeds). See docs/adr-001-modular-monolith.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DeliveryConfig

type DeliveryConfig = delivery.Config

DeliveryConfig re-exports the delivery subdomain's runtime snapshot.

type Deps

type Deps struct {
	Plans    repository.SubscribeRepo
	UserSubs repository.UserSubscriptionRepo
	Nodes    repository.NodeRepo
	Store    SubscriptionTransactor
	// NotifyPlanChanged broadcasts a plan update to connected devices.
	NotifyPlanChanged func()
	// Host is the site host list (first line is used for node fallbacks).
	Host string
	// IsTrialPlan reports whether the plan is the configured trial plan.
	IsTrialPlan func(planID int64) bool

	// Delivery dependencies.
	Clients repository.ClientRepo
	Users   repository.UserRepo
	Logs    repository.LogRepo
	// DeliveryConfig reads the runtime-mutable delivery configuration.
	DeliveryConfig func() DeliveryConfig

	// User-subscription administration dependencies.
	Devices repository.UserDeviceRepo
	Cache   repository.UserCacheRepo
	Traffic repository.TrafficRepo
	// FullStore is the transitional full-store dependency for the admin and
	// self-service subscription transactions.
	FullStore repository.Store
	Orders    repository.OrderRepo
	Inbox     repository.InboxRepo
	// SingleModel forbids holding more than one blocking subscription;
	// runtime-mutable, read per request.
	SingleModel func() bool
}

Deps declares everything the module needs; the composition root (internal/svc) provides them.

type RequestMeta

type RequestMeta = delivery.RequestMeta

RequestMeta re-exports the delivery subdomain's transport details.

type Service

type Service interface {
	// The client-application management for subscription delivery.
	CreateSubscribeApplication(ctx context.Context, req *dto.CreateSubscribeApplicationRequest) (*dto.SubscribeApplication, error)
	UpdateSubscribeApplication(ctx context.Context, req *dto.UpdateSubscribeApplicationRequest) (*dto.SubscribeApplication, error)
	DeleteSubscribeApplication(ctx context.Context, req *dto.DeleteSubscribeApplicationRequest) error
	GetSubscribeApplicationList(ctx context.Context, req *dto.GetSubscribeApplicationListRequest) (*dto.GetSubscribeApplicationListResponse, error)
	PreviewSubscribeTemplate(ctx context.Context, req *dto.PreviewSubscribeTemplateRequest) (*dto.PreviewSubscribeTemplateResponse, error)

	CreateSubscribe(ctx context.Context, req *dto.CreateSubscribeRequest) error
	UpdateSubscribe(ctx context.Context, req *dto.UpdateSubscribeRequest) error
	DeleteSubscribe(ctx context.Context, req *dto.DeleteSubscribeRequest) error
	BatchDeleteSubscribe(ctx context.Context, req *dto.BatchDeleteSubscribeRequest) error
	GetSubscribeList(ctx context.Context, req *dto.GetSubscribeListRequest) (*dto.GetSubscribeListResponse, error)
	GetSubscribeDetails(ctx context.Context, req *dto.GetSubscribeDetailsRequest) (*dto.Subscribe, error)
	SubscribeSort(ctx context.Context, req *dto.SubscribeSortRequest) error
	ResetAllSubscribeToken(ctx context.Context) (*dto.ResetAllSubscribeTokenResponse, error)
	CreateSubscribeGroup(ctx context.Context, req *dto.CreateSubscribeGroupRequest) error
	UpdateSubscribeGroup(ctx context.Context, req *dto.UpdateSubscribeGroupRequest) error
	DeleteSubscribeGroup(ctx context.Context, req *dto.DeleteSubscribeGroupRequest) error
	BatchDeleteSubscribeGroup(ctx context.Context, req *dto.BatchDeleteSubscribeGroupRequest) error
	GetSubscribeGroupList(ctx context.Context) (*dto.GetSubscribeGroupListResponse, error)

	QuerySubscribeList(ctx context.Context, req *dto.QuerySubscribeListRequest) (*dto.QuerySubscribeListResponse, error)
	QuerySubscribeGroupList(ctx context.Context) (*dto.QuerySubscribeGroupListResponse, error)
	QueryUserSubscribeNodeList(ctx context.Context) (*dto.QueryUserSubscribeNodeListResponse, error)

	// Deliver renders the client configuration for a subscription token.
	Deliver(ctx context.Context, meta RequestMeta, req *dto.SubscribeRequest) (*dto.SubscribeResponse, error)
	// IsUserAgentAllowed gates delivery by the configured user-agent allowlist.
	IsUserAgentAllowed(ctx context.Context, userAgent string) bool

	// User self-service subscription management.
	QueryUserSubscribe(ctx context.Context) (*dto.QueryUserSubscribeListResponse, error)
	// ResetOwnSubscribeToken is the self-service variant; ownership of the
	// subscription is enforced against the request context.
	ResetOwnSubscribeToken(ctx context.Context, req *dto.ResetUserSubscribeTokenRequest) error
	GetSubscribeLog(ctx context.Context, req *dto.GetSubscribeLogRequest) (*dto.GetSubscribeLogResponse, error)
	UpdateUserSubscribeNote(ctx context.Context, req *dto.UpdateUserSubscribeNoteRequest) error
	PreUnsubscribe(ctx context.Context, req *dto.PreUnsubscribeRequest) (*dto.PreUnsubscribeResponse, error)
	// Unsubscribe cancels in a subscription transaction and settles the
	// refund in a billing transaction, resumable via the idempotent inbox.
	Unsubscribe(ctx context.Context, req *dto.UnsubscribeRequest) error

	// Admin-side user subscription management.
	CreateUserSubscribe(ctx context.Context, req *dto.CreateUserSubscribeRequest) error
	DeleteUserSubscribe(ctx context.Context, req *dto.DeleteUserSubscribeRequest) error
	UpdateUserSubscribe(ctx context.Context, req *dto.UpdateUserSubscribeRequest) error
	GetUserSubscribe(ctx context.Context, req *dto.GetUserSubscribeListRequest) (*dto.GetUserSubscribeListResponse, error)
	GetUserSubscribeById(ctx context.Context, req *dto.GetUserSubscribeByIdRequest) (*dto.UserSubscribeDetail, error)
	GetUserSubscribeDevices(ctx context.Context, req *dto.GetUserSubscribeDevicesRequest) (*dto.GetUserSubscribeDevicesResponse, error)
	GetUserSubscribeLogs(ctx context.Context, req *dto.GetUserSubscribeLogsRequest) (*dto.GetUserSubscribeLogsResponse, error)
	GetUserSubscribeResetTrafficLogs(ctx context.Context, req *dto.GetUserSubscribeResetTrafficLogsRequest) (*dto.GetUserSubscribeResetTrafficLogsResponse, error)
	GetUserSubscribeTrafficLogs(ctx context.Context, req *dto.GetUserSubscribeTrafficLogsRequest) (*dto.GetUserSubscribeTrafficLogsResponse, error)
	ResetUserSubscribeToken(ctx context.Context, req *dto.ResetUserSubscribeTokenRequest) error
	ResetUserSubscribeTraffic(ctx context.Context, req *dto.ResetUserSubscribeTrafficRequest) error
	ToggleUserSubscribeStatus(ctx context.Context, req *dto.ToggleUserSubscribeStatusRequest) error
}

Service is the only surface other code may depend on; the implementation lives under internal/ where the compiler seals it off.

func New

func New(deps Deps) Service

type SubscriptionTransactor

type SubscriptionTransactor = plan.SubscriptionTransactor

SubscriptionTransactor re-exports the plan subdomain's transaction port.

Directories

Path Synopsis
internal
application
Service assembly for the client-application subdomain of the subscription module: managing the subscribe clients and previewing their delivery templates.
Service assembly for the client-application subdomain of the subscription module: managing the subscribe clients and previewing their delivery templates.
delivery
Package delivery implements the subscription delivery subdomain of the subscription module: token-authenticated rendering of client configs via the adapter, with notice placeholders for expired/exhausted subscriptions.
Package delivery implements the subscription delivery subdomain of the subscription module: token-authenticated rendering of client configs via the adapter, with notice placeholders for expired/exhausted subscriptions.
plan
Package plan implements the subscription plan management subdomain of the subscription module: plan and group CRUD, ordering and token resets.
Package plan implements the subscription plan management subdomain of the subscription module: plan and group CRUD, ordering and token resets.
selfsub
Package selfsub implements the user self-service subscription management of the subscription module: viewing, token reset, notes, and the two-phase cancellation with its billing refund.
Package selfsub implements the user self-service subscription management of the subscription module: viewing, token reset, notes, and the two-phase cancellation with its billing refund.
storefront
Package storefront implements the public subscription listings of the subscription module.
Package storefront implements the public subscription listings of the subscription module.
usersub
Package usersub implements the admin-side user subscription management of the subscription module.
Package usersub implements the admin-side user subscription management of the subscription module.

Jump to

Keyboard shortcuts

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