diff options
author | skullY <skullydazed@gmail.com> | 2020-02-23 22:37:25 -0800 |
---|---|---|
committer | skullydazed <skullydazed@users.noreply.github.com> | 2020-03-05 16:00:10 -0800 |
commit | 99850aabcad51dd4a46ee10c0f5349a4266084fe (patch) | |
tree | d59c25726ec8aa7209f15329a194f87f195de11d /docs/api_development_overview.md | |
parent | 3c98854044066744ad79d8abc27d93951860af6d (diff) | |
download | qmk_firmware-99850aabcad51dd4a46ee10c0f5349a4266084fe.tar.gz qmk_firmware-99850aabcad51dd4a46ee10c0f5349a4266084fe.zip |
Add API documentation
Diffstat (limited to 'docs/api_development_overview.md')
-rw-r--r-- | docs/api_development_overview.md | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/docs/api_development_overview.md b/docs/api_development_overview.md new file mode 100644 index 000000000..e55d03410 --- /dev/null +++ b/docs/api_development_overview.md | |||
@@ -0,0 +1,44 @@ | |||
1 | # QMK Compiler Development Guide | ||
2 | |||
3 | This page attempts to introduce developers to the QMK Compiler. It does not go into nitty gritty details- for that you should read code. What this will give you is a framework to hang your understanding on as you read the code. | ||
4 | |||
5 | # Overview | ||
6 | |||
7 | The QMK Compile API consists of a few movings parts: | ||
8 | |||
9 |  | ||
10 | |||
11 | API Clients interact exclusively with the API service. This is where they submit jobs, check status, and download results. The API service inserts compile jobs into [Redis Queue](https://python-rq.org) and checks both RQ and S3 for the results of those jobs. | ||
12 | |||
13 | Workers fetch new compile jobs from RQ, compile them, and then upload the source and the binary to an S3 compatible storage engine. | ||
14 | |||
15 | # Workers | ||
16 | |||
17 | QMK Compiler Workers are responsible for doing the actual building. When a worker pulls a job from RQ it does several things to complete that job: | ||
18 | |||
19 | * Make a fresh qmk_firmware checkout | ||
20 | * Use the supplied layers and keyboard metadata to build a `keymap.c` | ||
21 | * Build the firmware | ||
22 | * Zip a copy of the source | ||
23 | * Upload the firmware, source zip, and a metadata file to S3. | ||
24 | * Report the status of the job to RQ | ||
25 | |||
26 | # API Service | ||
27 | |||
28 | The API service is a relatively simple Flask application. There are a few main views you should understand. | ||
29 | |||
30 | ## @app.route('/v1/compile', methods=['POST']) | ||
31 | |||
32 | This is the main entrypoint for the API. A client's interaction starts here. The client POST's a JSON document describing their keyboard, and the API does some (very) basic validation of that JSON before submitting the compile job. | ||
33 | |||
34 | ## @app.route('/v1/compile/<string:job_id>', methods=['GET']) | ||
35 | |||
36 | This is the most frequently called endpoint. It pulls the job details from redis, if they're still available, or the cached job details on S3 if they're not. | ||
37 | |||
38 | ## @app.route('/v1/compile/<string:job_id>/download', methods=['GET']) | ||
39 | |||
40 | This method allows users to download the compiled firmware file. | ||
41 | |||
42 | ## @app.route('/v1/compile/<string:job_id>/source', methods=['GET']) | ||
43 | |||
44 | This method allows users to download the source for their firmware. | ||