Skip to content

postgres ​

go
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 ​

go
func NewPlanRepository() ports.PlanRepository

NewPlanRepository returns an in-memory stub implementation.

func NewSubscriptionRepository ​

go
func NewSubscriptionRepository() ports.SubscriptionRepository

NewSubscriptionRepository returns an in-memory stub implementation.

type BillingRepository ​

BillingRepository is real PostgreSQL persistence. No in-memory fallback is used.

go
type BillingRepository struct {
    DB            *pgxpool.Pool
    Audit         audit.TransactionalRecorderFactory
    Organizations org.BillingOrganizations
    // contains filtered or unexported fields
}

func NewBillingRepository ​

go
func NewBillingRepository(db *pgxpool.Pool, audit audit.TransactionalRecorderFactory, orgs org.BillingOrganizations) *BillingRepository

NewBillingRepository constructs the operation with its selected billing dependencies.

func (*BillingRepository) Append ​

go
func (r *BillingRepository) Append(c context.Context, op audit.OperationContext, e audit.EventInput) error

Append appends an approved event through the transaction-bound audit recorder.

func (*BillingRepository) Bound ​

go
func (r *BillingRepository) Bound(tx pgx.Tx) *BillingRepository

Bound creates a reader/writer using the caller-owned PostgreSQL transaction.

func (*BillingRepository) Current ​

go
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 ​

go
func (r *BillingRepository) Invoice(ctx context.Context, id string) (*p.Invoice, error)

Invoice exposes the selected persistent billing capability.

func (*BillingRepository) Invoices ​

go
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 ​

go
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 ​

go
func (r *BillingRepository) NextInvoiceNumber(ctx context.Context) (string, error)

NextInvoiceNumber allocates a sequence-backed human-readable charge number.

func (*BillingRepository) PaidTotal ​

go
func (r *BillingRepository) PaidTotal(ctx context.Context, id string) (int64, error)

PaidTotal sums authoritative non-voided received payments.

func (*BillingRepository) Payment ​

go
func (r *BillingRepository) Payment(ctx context.Context, id string) (*p.Payment, error)

Payment exposes the selected persistent billing capability.

func (*BillingRepository) PaymentInvoice ​

go
func (r *BillingRepository) PaymentInvoice(ctx context.Context, id string) (string, error)

PaymentInvoice reads immutable invoice linkage before the invoice-first lock.

func (*BillingRepository) Payments ​

go
func (r *BillingRepository) Payments(c context.Context, q p.Query) ([]p.Payment, error)

Payments exposes the selected persistent billing capability.

func (*BillingRepository) Plan ​

go
func (r *BillingRepository) Plan(ctx context.Context, id string) (*p.Plan, error)

Plan exposes the selected persistent billing capability.

func (*BillingRepository) Plans ​

go
func (r *BillingRepository) Plans(c context.Context, q p.Query) ([]p.Plan, error)

Plans exposes the selected persistent billing capability.

func (*BillingRepository) Remember ​

go
func (r *BillingRepository) Remember(ctx context.Context, actor, operation, scope, key string, value any) error

Remember saves a retry fingerprint/result within the business transaction.

func (*BillingRepository) Retry ​

go
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 ​

go
func (r *BillingRepository) Run(ctx context.Context, fn func(ports.BillingTransaction) error) error

Run commits a billing callback and its audit records in one transaction.

func (*BillingRepository) SaveInvoice ​

go
func (r *BillingRepository) SaveInvoice(c context.Context, v *p.Invoice) error

SaveInvoice persists the validated record within the protected transaction.

func (*BillingRepository) SavePayment ​

go
func (r *BillingRepository) SavePayment(c context.Context, v *p.Payment) error

SavePayment persists the validated record within the protected transaction.

func (*BillingRepository) SavePlan ​

go
func (r *BillingRepository) SavePlan(c context.Context, v *p.Plan) error

SavePlan persists the validated record within the protected transaction.

func (*BillingRepository) SaveSubscription ​

go
func (r *BillingRepository) SaveSubscription(c context.Context, v *p.Subscription) error

SaveSubscription persists the validated record within the protected transaction.

func (*BillingRepository) Subscription ​

go
func (r *BillingRepository) Subscription(ctx context.Context, id string) (*p.Subscription, error)

Subscription exposes the selected persistent billing capability.

func (*BillingRepository) SubscriptionOrganization ​

go
func (r *BillingRepository) SubscriptionOrganization(ctx context.Context, id string) (string, error)

SubscriptionOrganization reads immutable tenant linkage without taking a subscription lock.

func (*BillingRepository) Subscriptions ​

go
func (r *BillingRepository) Subscriptions(c context.Context, q p.Query) ([]p.Subscription, error)

Subscriptions exposes the selected persistent billing capability.

Generated by gomarkdoc

Documentation follows the source. Planned contracts are marked explicitly.