Documentation
¶
Overview ¶
Package billing is the module manifest: what a tenant is paying for.
It is the shape every module follows — contracts/, internal/, and one exported function taking a struct of typed dependencies and returning a module.Module — with one asymmetry worth naming at the top. Plans are a collection an administrator maintains, so they are a rest.Spec. The subscription is not a collection: a tenant is the customer, so it has one, and a singleton has no list, no create and no id in its path. Its three routes are internal/handler.go, the only hand-written ones here.
Renewal is the other thing to read first. Taking money is a call to somebody else's machine, so it never happens inside a database transaction: the job asks the service what is owed, closes that transaction, charges, and opens another to record the answer. internal/renew.go is the shape.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Manual = internal.NewManual
Manual is the PaymentProvider that records what is owed and moves no money. main wires it, or whatever a deployment has instead, so the choice is visible in the file that composes the application — as the mailer is.
var Migrations = db.MigrationSource{ Owner: "billing", Files: db.Sub(schema, "migrations"), Adopts: []db.Adoption{{Owner: "platformkit", Versions: []int64{16, 22}}}, }
Migrations is this module's SQL as one source — plans, subscriptions and their billing anchor — owned as "billing". The manifest hands the kernel the same files and adoption, and a test composes the schema it needs beside the foundation: dbtest.Schema(t, billing.Migrations).
The files keep the version numbers they had when the foundation applied them under its own name, so an installation migrated before this module owned its SQL is adopted by checksum rather than migrated again (see db.Adoption and docs/adr/0011). New files continue from the highest number.
Functions ¶
func Module ¶
Module is the manifest, and the plan answer beside it, as user's and notification's modules return their services: the kernel asks this module what a tenant's plan includes, for the operations whose declaration names a feature, and this is where an application is handed something to answer with.
Types ¶
type Deps ¶
type Deps struct {
// Tenants is how the nightly renewal reaches every tenant.
Tenants jobs.TenantLister
// Payments takes the money. There is one implementation here, Manual; the
// ones that speak to a payment processor live outside this repository.
Payments contracts.PaymentProvider
// RenewEvery replaces the nightly schedule with an interval, for a test
// that cannot wait until two in the morning. Zero means the schedule.
RenewEvery time.Duration
}
Deps is what this module cannot make for itself.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package contracts is everything another module, an app or a test may know about billing: the two entities, the events, the permissions, the payment provider this module needs somebody else to satisfy, and the Service interface.
|
Package contracts is everything another module, an app or a test may know about billing: the two entities, the events, the permissions, the payment provider this module needs somebody else to satisfy, and the Service interface. |
|
billingtest
Package billingtest is the conformance suite for contracts.Service, and a fake that passes it.
|
Package billingtest is the conformance suite for contracts.Service, and a fake that passes it. |
|
Package internal is every implementation of the billing module.
|
Package internal is every implementation of the billing module. |