postgres
import "github.com/prescriptoo/prescriptoo-api/services/subscription/internal/adapters/postgres"Package postgres provides PostgreSQL driven adapter implementations. Legacy prototype definitions in this file are unmounted; production uses the billing implementation.
Index
- func NewPlanRepository() ports.PlanRepository
- func NewSubscriptionRepository() ports.SubscriptionRepository
- type BillingRepository
- func NewBillingRepository(db *pgxpool.Pool, audit audit.TransactionalRecorderFactory, orgs org.BillingOrganizations) *BillingRepository
- func (r *BillingRepository) Append(c context.Context, op audit.OperationContext, e audit.EventInput) error
- func (r *BillingRepository) Bound(tx pgx.Tx) *BillingRepository
- func (r *BillingRepository) Current(ctx context.Context, ids []string) (map[string]p.CurrentSubscription, error)
- func (r *BillingRepository) Invoice(ctx context.Context, id string) (*p.Invoice, error)
- func (r *BillingRepository) Invoices(c context.Context, q p.Query, issued bool) ([]p.Invoice, error)
- func (r *BillingRepository) LockOrganization(c context.Context, id string) (org.BillingOrganization, error)
- func (r *BillingRepository) NextInvoiceNumber(ctx context.Context) (string, error)
- func (r *BillingRepository) PaidTotal(ctx context.Context, id string) (int64, error)
- func (r *BillingRepository) Payment(ctx context.Context, id string) (*p.Payment, error)
- func (r *BillingRepository) PaymentInvoice(ctx context.Context, id string) (string, error)
- func (r *BillingRepository) Payments(c context.Context, q p.Query) ([]p.Payment, error)
- func (r *BillingRepository) Plan(ctx context.Context, id string) (*p.Plan, error)
- func (r *BillingRepository) Plans(c context.Context, q p.Query) ([]p.Plan, error)
- func (r *BillingRepository) Remember(ctx context.Context, actor, operation, scope, key string, value any) error
- func (r *BillingRepository) Retry(ctx context.Context, actor, operation, scope, key string) (json.RawMessage, error)
- func (r *BillingRepository) Run(ctx context.Context, fn func(ports.BillingTransaction) error) error
- func (r *BillingRepository) SaveInvoice(c context.Context, v *p.Invoice) error
- func (r *BillingRepository) SavePayment(c context.Context, v *p.Payment) error
- func (r *BillingRepository) SavePlan(c context.Context, v *p.Plan) error
- func (r *BillingRepository) SaveSubscription(c context.Context, v *p.Subscription) error
- func (r *BillingRepository) Subscription(ctx context.Context, id string) (*p.Subscription, error)
- func (r *BillingRepository) SubscriptionOrganization(ctx context.Context, id string) (string, error)
- func (r *BillingRepository) Subscriptions(c context.Context, q p.Query) ([]p.Subscription, error)
func NewPlanRepository
func NewPlanRepository() ports.PlanRepositoryNewPlanRepository returns an in-memory stub implementation.
func NewSubscriptionRepository
func NewSubscriptionRepository() ports.SubscriptionRepositoryNewSubscriptionRepository returns an in-memory stub implementation.
type BillingRepository
BillingRepository is real PostgreSQL persistence. No in-memory fallback is used.
type BillingRepository struct {
DB *pgxpool.Pool
Audit audit.TransactionalRecorderFactory
Organizations org.BillingOrganizations
// contains filtered or unexported fields
}func NewBillingRepository
func NewBillingRepository(db *pgxpool.Pool, audit audit.TransactionalRecorderFactory, orgs org.BillingOrganizations) *BillingRepositoryNewBillingRepository constructs the operation with its selected billing dependencies.
func (*BillingRepository) Append
func (r *BillingRepository) Append(c context.Context, op audit.OperationContext, e audit.EventInput) errorAppend appends an approved event through the transaction-bound audit recorder.
func (*BillingRepository) Bound
func (r *BillingRepository) Bound(tx pgx.Tx) *BillingRepositoryBound creates a reader/writer using the caller-owned PostgreSQL transaction.
func (*BillingRepository) Current
func (r *BillingRepository) Current(ctx context.Context, ids []string) (map[string]p.CurrentSubscription, error)Current identifies stored states that reserve the current agreement slot.
func (*BillingRepository) Invoice
func (r *BillingRepository) Invoice(ctx context.Context, id string) (*p.Invoice, error)Invoice exposes the selected persistent billing capability.
func (*BillingRepository) Invoices
func (r *BillingRepository) Invoices(c context.Context, q p.Query, issued bool) ([]p.Invoice, error)Invoices exposes the selected persistent billing capability.
func (*BillingRepository) LockOrganization
func (r *BillingRepository) LockOrganization(c context.Context, id string) (org.BillingOrganization, error)LockOrganization delegates organization locking and relationship counts to their owner.
func (*BillingRepository) NextInvoiceNumber
func (r *BillingRepository) NextInvoiceNumber(ctx context.Context) (string, error)NextInvoiceNumber allocates a sequence-backed human-readable charge number.
func (*BillingRepository) PaidTotal
func (r *BillingRepository) PaidTotal(ctx context.Context, id string) (int64, error)PaidTotal sums authoritative non-voided received payments.
func (*BillingRepository) Payment
func (r *BillingRepository) Payment(ctx context.Context, id string) (*p.Payment, error)Payment exposes the selected persistent billing capability.
func (*BillingRepository) PaymentInvoice
func (r *BillingRepository) PaymentInvoice(ctx context.Context, id string) (string, error)PaymentInvoice reads immutable invoice linkage before the invoice-first lock.
func (*BillingRepository) Payments
func (r *BillingRepository) Payments(c context.Context, q p.Query) ([]p.Payment, error)Payments exposes the selected persistent billing capability.
func (*BillingRepository) Plan
func (r *BillingRepository) Plan(ctx context.Context, id string) (*p.Plan, error)Plan exposes the selected persistent billing capability.
func (*BillingRepository) Plans
func (r *BillingRepository) Plans(c context.Context, q p.Query) ([]p.Plan, error)Plans exposes the selected persistent billing capability.
func (*BillingRepository) Remember
func (r *BillingRepository) Remember(ctx context.Context, actor, operation, scope, key string, value any) errorRemember saves a retry fingerprint/result within the business transaction.
func (*BillingRepository) Retry
func (r *BillingRepository) Retry(ctx context.Context, actor, operation, scope, key string) (json.RawMessage, error)Retry serializes a scoped retry key and retrieves its committed result.
func (*BillingRepository) Run
func (r *BillingRepository) Run(ctx context.Context, fn func(ports.BillingTransaction) error) errorRun commits a billing callback and its audit records in one transaction.
func (*BillingRepository) SaveInvoice
func (r *BillingRepository) SaveInvoice(c context.Context, v *p.Invoice) errorSaveInvoice persists the validated record within the protected transaction.
func (*BillingRepository) SavePayment
func (r *BillingRepository) SavePayment(c context.Context, v *p.Payment) errorSavePayment persists the validated record within the protected transaction.
func (*BillingRepository) SavePlan
func (r *BillingRepository) SavePlan(c context.Context, v *p.Plan) errorSavePlan persists the validated record within the protected transaction.
func (*BillingRepository) SaveSubscription
func (r *BillingRepository) SaveSubscription(c context.Context, v *p.Subscription) errorSaveSubscription persists the validated record within the protected transaction.
func (*BillingRepository) Subscription
func (r *BillingRepository) Subscription(ctx context.Context, id string) (*p.Subscription, error)Subscription exposes the selected persistent billing capability.
func (*BillingRepository) SubscriptionOrganization
func (r *BillingRepository) SubscriptionOrganization(ctx context.Context, id string) (string, error)SubscriptionOrganization reads immutable tenant linkage without taking a subscription lock.
func (*BillingRepository) Subscriptions
func (r *BillingRepository) Subscriptions(c context.Context, q p.Query) ([]p.Subscription, error)Subscriptions exposes the selected persistent billing capability.
Generated by gomarkdoc