payday

module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0

README

payday

A framework for gRPC applications: declare an entity once, and what follows from it is generated rather than remembered.

$ go get -tool github.com/lesomnus/payday/cmd/pd
$ go tool pd new github.com/acme/widget .

That writes a schema, a server, a config file and a React page, and prints the handful of commands that turn them into a running app.

What a schema says

message Robot {
  bytes  id     = 1 [(orm.field) = {type: TYPE_UUID, key: true, default: ""}];
  Tenant tenant = 2 [(orm.edge) = {immutable: true}];
  string alias  = 4;

  google.protobuf.Timestamp date_erased = 14 [(orm.field) = {erased: {}}];

  option (orm.message)   = {rpc: {crud: true}};
  option (payday.entity) = {domain: 7};
}

Two things had to be said and one of them is a field.

domain: 7 is what this entity's identifiers carry, and generation refuses an entity without one: an identifier that says nothing about what it names is one nothing can check.

date_erased says Erase stamps the row rather than destroying it. That is refused too, in both directions — an entity that says neither this nor erase: {hard: {}} does not generate, because payday cannot add a field to your schema and so cannot make "soft" the silent answer.

Tenancy is the silence. Saying nothing means behind the wall, by the edge called tenant, and the two ways of being wrong are why: assume a wall that is not there and every row disappears within minutes; assume none that should be and everything is visible to everybody, nothing breaks, and no test goes red. The dangerous answer is the one you write down (global: {}), and grepping for it finds every one of them.

What comes out

sink, err := pd.NewSink(db,
    bare.WithMinter(pd.Minter()),   // every row named by what it is
    bare.WithScope(pd.Wall()),      // every read behind the tenant it belongs to
)

Nothing else. There is no wall.go to write and no method per entity to remember: an entity added to the schema arrives with its wall already on it.

Also generated, from the same declaration: the CRUD service, a List with a cursor that cannot skip a row, a Watch that keeps a client's copy current, the layer that refuses an Add into a tenant the caller cannot see, the audit trail written inside the transaction that changed something, and the TypeScript half.

The identifier

A UUIDv8 carrying one byte that says what kind of thing it names.

0199c3f4-2a10-8abc-8a03-9f2e1c4d5b6a
                    ^^ robot

It buys three things a plain UUID cannot: a reference checked before the database is, a row that can still be named after it is erased, and a lookup that does not have to try every table. See pdid.

Whose names these are

Tenant, Holder, Audit and Outbox are payday's entities and they land in your proto package. A caller of your app says /app.TenantService/Get, not /payday.TenantService/Get — a tenant and a holder are your customers and your people, and nobody calling your API should have to learn the name of the framework it was built with.

One name survives on the wire, payday.ResourceService, and it is a transport rather than a domain concept: a live stream of what changed, of whatever entity, each row sent as its subscriber may read it. It keeps its name the way grpc.health.v1.Health does, so a client written once finds it in any payday app.

Layout

pdid the identifier, its domain, and the registry generated code fills
slug @acme/arm-01#robot — the human-readable way to name a row
frame who a request is from, and what they may see
auth reading a credential: a header, a certificate, a token
gate what a caller may do, and the seam a deployment injects
account a call of an account served as one of its memberships, or as itself
audit the trail, written in the transaction that changed something
watch · spin publishing what changed, and the loops that do it
meter what each tenant holds, measured and handed to a billing service's client
entitle what each tenant is entitled to, copied from a source of grants and read in the write's transaction
web the port a browser reaches
version refusing a server whose payday moved
rename · valid what a migration asks of a database before it finds a table, a column or an index by name: what was renamed moved first, an index left invalid refused, and a column nothing writes that takes no row without a value refused
config · grpcx · pderr what an app was configured with, how it is served, how it refuses
ts @lesomnus/payday — the client half
cmd/pd new, gen, entity, sandbox, doctor
internal/apptest the app payday is tried against
$ ./scripts/test.sh -count=1      # both modules; `go test ./...` does not reach apptest
$ go tool pd gen --check --ts internal/apptest

The schema

buf.build/payday/payday, pushed under the dev label while the option is still moving.

$ buf push --exclude-unnamed --label dev

An app pins it in buf.lock, and pd gen only writes that lock when nothing has. So an app that has generated once stays where it was pinned until buf dep update is run — which is the app's decision to make and not payday's.

Licence

Apache 2.0.

Directories

Path Synopsis
Package access is the access record: who read or wrote whose personal data, from where, when, and how the call ended (payday#111).
Package access is the access record: who read or wrote whose personal data, from where, when, and how the call ended (payday#111).
Package account is the account layer: what an app whose holders are memberships of accounts needs to serve a call as one of them (payday#184).
Package account is the account layer: what an app whose holders are memberships of accounts needs to serve a call as one of them (payday#184).
Package audit is the trail of what was changed, and by whom.
Package audit is the trail of what was changed, and by whom.
Package auth says who a caller is.
Package auth says who a caller is.
authoidc
Package authoidc reads the token an external identity provider issued.
Package authoidc reads the token an external identity provider issued.
authsession
Package authsession is the browser's half of authentication.
Package authsession is the browser's half of authentication.
cmd
pd command
Command pd generates a payday app from its schema, and says when the two have come apart.
Command pd generates a payday app from its schema, and says when the two have come apart.
protoc-gen-pd command
protoc-gen-pd writes what a payday schema declared into the code that enforces it.
protoc-gen-pd writes what a payday schema declared into the code that enforces it.
Package config is the blocks every payday app is configured with.
Package config is the blocks every payday app is configured with.
brokerpg
Package brokerpg makes "postgres" a broker a configuration may name.
Package brokerpg makes "postgres" a broker a configuration may name.
dbpgx
Package dbpgx makes "pgx" a driver a configuration may name.
Package dbpgx makes "pgx" a driver a configuration may name.
dbsqlite3
Package dbsqlite3 makes "sqlite3" a driver a configuration may name.
Package dbsqlite3 makes "sqlite3" a driver a configuration may name.
dbsqlite3wasm
Package dbsqlite3wasm makes "sqlite3-wasm" a driver a configuration may name.
Package dbsqlite3wasm makes "sqlite3-wasm" a driver a configuration may name.
leasepg
Package leasepg makes "postgres" a lease a configuration may name (#54).
Package leasepg makes "postgres" a lease a configuration may name (#54).
signerpkcs11
Package signerpkcs11 makes `pkcs11:` a key `audit.checkpoints.key` may name (#52): a key in an HSM, a cloud's HSM, a smart card or SoftHSM, by its RFC 7512 URI, signed with through `trail/trailpkcs11`.
Package signerpkcs11 makes `pkcs11:` a key `audit.checkpoints.key` may name (#52): a key in an HSM, a cloud's HSM, a smart card or SoftHSM, by its RFC 7512 URI, signed with through `trail/trailpkcs11`.
signertpm
Package signertpm makes `tpm:` a key `audit.checkpoints.key` may name (#52): a key at a persistent handle of the machine's TPM 2.0, or its vTPM, signed with through `trail/trailtpm`.
Package signertpm makes `tpm:` a key `audit.checkpoints.key` may name (#52): a key at a persistent handle of the machine's TPM 2.0, or its vTPM, signed with through `trail/trailtpm`.
signervault
Package signervault makes `hashivault://` a key `audit.checkpoints.key` may name (#52): a key in Vault's Transit secrets engine, or OpenBao's, signed with through `trail/trailvault`.
Package signervault makes `hashivault://` a key `audit.checkpoints.key` may name (#52): a key in Vault's Transit secrets engine, or OpenBao's, signed with through `trail/trailvault`.
witnesslog
Package witnesslog registers the log witness (trail/witnesslog) with config: an app that imports it names one in `audit.checkpoints.witnesses` as `log:`,
Package witnesslog registers the log witness (trail/witnesslog) with config: an app that imports it names one in `audit.checkpoints.witnesses` as `log:`,
witnessrekor
Package witnessrekor registers the Rekor witness (trail/witnessrekor) with config: an app that imports it names a log in `audit.checkpoints.witnesses` as `rekor:`, its URL, `key=` the PEM file of the log's key and `v=2` for a log on tiles,
Package witnessrekor registers the Rekor witness (trail/witnessrekor) with config: an app that imports it names a log in `audit.checkpoints.witnesses` as `rekor:`, its URL, `key=` the PEM file of the log's key and `v=2` for a log on tiles,
witnessstore
Package witnessstore registers the store witness (trail/witnessstore) with config: an app that imports it names one in `audit.checkpoints.witnesses` as `store:` and a directory of its own,
Package witnessstore registers the store witness (trail/witnessstore) with config: an app that imports it names one in `audit.checkpoints.witnesses` as `store:` and a directory of its own,
Package entitle keeps a tenant's copy of what it is entitled to, in the app's own database, and reads it inside the transaction of the write it decides (payday#185).
Package entitle keeps a tenant's copy of what it is entitled to, in the app's own database, and reads it inside the transaction of the write it decides (payday#185).
Package frame carries who a request is from.
Package frame carries who a request is from.
Package gate decides what the caller of a request may do with it.
Package gate decides what the caller of a request may do with it.
Package grpcx holds the plumbing the app is served with: what every call goes through before it reaches a service server.
Package grpcx holds the plumbing the app is served with: what every call goes through before it reaches a service server.
Package header is the part of a row that is the same whatever entity it belongs to, read from any of them.
Package header is the part of a row that is the same whatever entity it belongs to, read from any of them.
internal
pdcli
Package pdcli is what `pd` does, kept out of `main` so that it can be tested by calling it rather than by running a binary and reading its output.
Package pdcli is what `pd` does, kept out of `main` so that it can be tested by calling it rather than by running a binary and reading its output.
pdgen
Package pdgen reads what a schema declared to payday and writes out what follows from it.
Package pdgen reads what a schema declared to payday and writes out what follows from it.
Package meter measures what each tenant holds -- its assets, its members, the bytes it stores -- and hands the readings to a sink, which is the billing service's client (payday#186).
Package meter measures what each tenant holds -- its assets, its members, the bytes it stores -- and hands the readings to a sink, which is the billing service's client (payday#186).
Package notify provides topic notifications with application-defined access and lazy, independently owned receipts.
Package notify provides topic notifications with application-defined access and lazy, independently owned receipts.
Package past records what an app's operations did and what its resources were, and reads it back (payday#151).
Package past records what an app's operations did and what its resources were, and reads it back (payday#151).
Package pdcmd is the commands every payday app has, ready to be mounted on the app's own binary.
Package pdcmd is the commands every payday app has, ready to be mounted on the app's own binary.
Package pderr is the shape of a refusal: which field was wrong, and why.
Package pderr is the shape of a refusal: which field was wrong, and why.
Package pdid is the identifier every row of a payday app is named by.
Package pdid is the identifier every row of a payday app is named by.
Package pdpb is what payday's own `.proto` files generate: the options a schema is declared with, and the two services payday serves on an app's behalf.
Package pdpb is what payday's own `.proto` files generate: the options a schema is declared with, and the two services payday serves on an app's behalf.
Package pdtest is what a test of a payday app is given: assertions that know about gRPC, a connection that never leaves the process, and a database of this test's own.
Package pdtest is what a test of a payday app is given: assertions that know about gRPC, a connection that never leaves the process, and a database of this test's own.
Package rbac evaluates tenant-wide method roles from named holders, groups and bindings.
Package rbac evaluates tenant-wide method roles from named holders, groups and bindings.
rbacfile
Package rbacfile provides read-only YAML method policies.
Package rbacfile provides read-only YAML method policies.
Package rename moves what an earlier build made under one name to the name this build makes it under, before a migration looks for it.
Package rename moves what an earlier build made under one name to the name this build makes it under, before a migration looks for it.
Package resource serves operations across resource types.
Package resource serves operations across resource types.
resourcecel
Package resourcecel is the language a Watch filter is written in: a boolean CEL expression over `event`, the pdpb.WatchEvent the subscriber would be sent (payday#74).
Package resourcecel is the language a Watch filter is written in: a boolean CEL expression over `event`, the pdpb.WatchEvent the subscriber would be sent (payday#74).
resourcesql
Package resourcesql evaluates existing Ent read predicates against an immutable resource image.
Package resourcesql evaluates existing Ent read predicates against an immutable resource image.
Package schema holds payday's own entities and what they are allowed to become in an app.
Package schema holds payday's own entities and what they are allowed to become in an app.
Package seen remembers, for the rest of a transaction, what the layers in front of every write have already asked about the rows it names.
Package seen remembers, for the rest of a transaction, what the layers in front of every write have already asked about the rows it names.
Package slug is the human-readable way to name a row.
Package slug is the human-readable way to name a row.
Package spin runs what the layers of a server have to do besides answering requests.
Package spin runs what the layers of a server have to do besides answering requests.
spinpg
Package spinpg is a spin.Lease over PostgreSQL's advisory locks (#54).
Package spinpg is a spin.Lease over PostgreSQL's advisory locks (#54).
Package trail is what happens to the record of what happened, after long enough.
Package trail is what happens to the record of what happened, after long enough.
internal/signed
Package signed is what the adapters beside it share (#52): a device's signature put in the form a checkpoint's verifier reads, and checked against the key's public half before it is handed over.
Package signed is what the adapters beside it share (#52): a device's signature put in the form a checkpoint's verifier reads, and checked against the key's public half before it is handed over.
trailpkcs11
Package trailpkcs11 signs the trail's checkpoints with a key in a PKCS #11 token (#52): an HSM on the network or in the machine, a cloud's HSM through the library its vendor ships (AWS CloudHSM, Google's kmsp11, Thales Luna, YubiHSM), a smart card, or SoftHSM to try one.
Package trailpkcs11 signs the trail's checkpoints with a key in a PKCS #11 token (#52): an HSM on the network or in the machine, a cloud's HSM through the library its vendor ships (AWS CloudHSM, Google's kmsp11, Thales Luna, YubiHSM), a smart card, or SoftHSM to try one.
trailtpm
Package trailtpm signs the trail's checkpoints with a key in a TPM 2.0 (#52): the machine's own, or a virtual machine's vTPM, which every cloud gives a VM that asks for one (shielded, trusted launch, Nitro).
Package trailtpm signs the trail's checkpoints with a key in a TPM 2.0 (#52): the machine's own, or a virtual machine's vTPM, which every cloud gives a VM that asks for one (shielded, trusted launch, Nitro).
trailvault
Package trailvault signs the trail's checkpoints with a key in HashiCorp Vault's Transit secrets engine, or OpenBao's, which speaks the same API (#52).
Package trailvault signs the trail's checkpoints with a key in HashiCorp Vault's Transit secrets engine, or OpenBao's, which speaks the same API (#52).
witnesslog
Package witnesslog is a witness that tells (payday#115; see trail.Witness): a line of the log for every checkpoint the trail takes, and a gauge of its number, `payday.trail.checkpoint`.
Package witnesslog is a witness that tells (payday#115; see trail.Witness): a line of the log for every checkpoint the trail takes, and a gauge of its number, `payday.trail.checkpoint`.
witnessrekor
Package witnessrekor is a witness that logs every checkpoint to a Rekor transparency log (payday#115; see trail.Witness): one of the deployment's own, or -- by the operator's choice, and see payday's runtime docs first -- the public instance Sigstore runs.
Package witnessrekor is a witness that logs every checkpoint to a Rekor transparency log (payday#115; see trail.Witness): one of the deployment's own, or -- by the operator's choice, and see payday's runtime docs first -- the public instance Sigstore runs.
witnessrekor/rekortest
Package rekortest is a Rekor log for a test (payday#115): v1's API or v2's write API and tiles, on httptest, over a real RFC 6962 tree, its heads signed by an ECDSA key of its own.
Package rekortest is a Rekor log for a test (payday#115): v1's API or v2's write API and tiles, on httptest, over a real RFC 6962 tree, its heads signed by an ECDSA key of its own.
witnessstore
Package witnessstore is a witness that keeps every statement it hears in a flob store of its own (payday#115; see trail.Witness).
Package witnessstore is a witness that keeps every statement it hears in a flob store of its own (payday#115; see trail.Witness).
Package valid refuses a database a migration would take for this build's shape and is not: one with an index PostgreSQL has not finished, which the migration takes for one it made (Indexes), and one with a column nothing this build writes that takes no row without a value (Columns).
Package valid refuses a database a migration would take for this build's shape and is not: one with an index PostgreSQL has not finished, which the migration takes for one it made (Indexes), and one with a column nothing this build writes that takes no row without a value (Columns).
Package version says what build is running.
Package version says what build is running.
Package watch publishes what a call changed, once its transaction has committed.
Package watch publishes what a call changed, once its transaction has committed.
watchpg
Package watchpg is a watch.Broker over PostgreSQL's `LISTEN`/`NOTIFY`.
Package watchpg is a watch.Broker over PostgreSQL's `LISTEN`/`NOTIFY`.
Package web is the app on a port a browser can reach.
Package web is the app on a port a browser can reach.

Jump to

Keyboard shortcuts

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