|
| 1 | +# Generation |
| 2 | + |
| 3 | +MobilityAPI-Python is a tier over MEOS, so what it knows about MEOS is |
| 4 | +generated from the MEOS-API catalog rather than kept by hand. The generator |
| 5 | +lives in `tools/codegen.py`, its output is committed, and CI derives the catalog |
| 6 | +from MobilityDB master, regenerates against it, and refuses a difference. This |
| 7 | +is the arrangement of MobilityAPI's Go tier, whose generator is |
| 8 | +`tools/codegen/main.go`. |
| 9 | + |
| 10 | +## What is generated |
| 11 | + |
| 12 | +`mobilityapi/catalog_gen.py` holds `FUNCTIONS`, one entry per MEOS function the |
| 13 | +catalog states as exposable, ordered by name. Each entry is the catalog's own |
| 14 | +entry restricted to the keys the dispatcher reads: `name`, `category`, |
| 15 | +`params`, `returnType`, `network`, `wire` and `doc`. |
| 16 | +`FunctionSignature.from_catalog_entry` reads an entry of the table exactly as it |
| 17 | +reads one of the catalog, and the `Dispatcher` serves every function of the |
| 18 | +table: `GET /catalog` lists them and `POST /functions/{name}` invokes one. |
| 19 | + |
| 20 | +Run it against a catalog: |
| 21 | + |
| 22 | +```bash |
| 23 | +python3 tools/codegen.py -catalog <meos-idl.json> -o mobilityapi/catalog_gen.py |
| 24 | +``` |
| 25 | + |
| 26 | +A catalog entry without one of the keys the dispatcher reads, or a catalog |
| 27 | +stating no function as exposable, stops the generator. |
| 28 | + |
| 29 | +## Where the facts come from |
| 30 | + |
| 31 | +`meos-idl.json` is the machine-readable description of the MEOS C library that |
| 32 | +[MEOS-API](https://github.com/MobilityDB/MEOS-API) derives from the MEOS headers |
| 33 | +and sources, and that every binding in the ecosystem generates from. Whether a |
| 34 | +function is exposable, and how each parameter and the result travel over the |
| 35 | +wire, is the catalog's `network` and `wire` projection, which MEOS-API derives |
| 36 | +from each function's types, SQL name and group. |
| 37 | + |
| 38 | +The catalog is a derived artifact of one MobilityDB commit, so it is never |
| 39 | +committed. CI derives it with |
| 40 | +`MobilityDB/MEOS-API/.github/actions/provision-meos@master`, the action every |
| 41 | +binding uses, and the `generated-table` job of `.github/workflows/python.yml` |
| 42 | +regenerates the table against it. A function MEOS gains, loses or changes on |
| 43 | +master arrives there as a difference to regenerate. |
| 44 | + |
| 45 | +To derive the catalog by hand, run MEOS-API's `tools/provision-meos.sh` over a |
| 46 | +MobilityDB checkout: |
| 47 | + |
| 48 | +```bash |
| 49 | +<MEOS-API>/tools/provision-meos.sh --mdb-src <MobilityDB> --catalog-out meos-idl.json |
| 50 | +``` |
0 commit comments