| 1 | package dbreads |
| 2 | |
| 3 | // The reads route's 200 body is newline-delimited JSON, one Line per line |
| 4 | // (spec §5.5 step 6). MaxLineBytes bounds one line: a ChunkBytes chunk, |
| 5 | // sealed and base64-encoded, is about 350 KiB, and a pull's PullChunkBytes |
| 6 | // chunk about 1.4 MB. |
| 7 | const MaxLineBytes = 2 << 20 |
| 8 | |
| 9 | // Wait lines name what the console is waiting on; ended lines say why the |
| 10 | // response ends without a result. |
| 11 | const ( |
| 12 | WaitPickup = "pickup" |
| 13 | WaitReading = "reading" |
| 14 | EndedNotPicked = "not-picked" // the CLI says DBF-3 |
| 15 | EndedNoResult = "no-result" // the CLI says DBF-12 |
| 16 | ) |
| 17 | |
| 18 | // Line is one outcome: admitted (the read's id), picked (the owner box), |
| 19 | // one chunk in sequence, a wait, an ended, or the result, which comes last. |
| 20 | // The ended line is additive to spec §5.5's list ("from here every outcome |
| 21 | // is a line in that body"): it lets the CLI tell nobody picking the read |
| 22 | // (DBF-3) from a read that did not finish (DBF-12), which a console restart |
| 23 | // or a dropped connection also ends with no result. |
| 24 | type Line struct { |
| 25 | Admitted string `json:"admitted,omitempty"` |
| 26 | Picked string `json:"picked,omitempty"` |
| 27 | Chunk int64 `json:"chunk,omitempty"` |
| 28 | Data []byte `json:"data,omitempty"` |
| 29 | Wait string `json:"wait,omitempty"` |
| 30 | Ended string `json:"ended,omitempty"` |
| 31 | Result *Result `json:"result,omitempty"` |
| 32 | } |
| 33 | |
| 34 | // ReadBody is the POST …/db/{host}/reads body (spec §5.5 step 2). |
| 35 | type ReadBody struct { |
| 36 | Op string `json:"op"` |
| 37 | SQL string `json:"sql"` |
| 38 | At string `json:"at"` |
| 39 | ReplyKey string `json:"reply_key"` |
| 40 | } |
| 41 | |