package dbreads // The reads route's 200 body is newline-delimited JSON, one Line per line // (spec §5.5 step 6). MaxLineBytes bounds one line: a ChunkBytes chunk, // sealed and base64-encoded, is about 350 KiB, and a pull's PullChunkBytes // chunk about 1.4 MB. const MaxLineBytes = 2 << 20 // Wait lines name what the console is waiting on; ended lines say why the // response ends without a result. const ( WaitPickup = "pickup" WaitReading = "reading" EndedNotPicked = "not-picked" // the CLI says DBF-3 EndedNoResult = "no-result" // the CLI says DBF-12 ) // Line is one outcome: admitted (the read's id), picked (the owner box), // one chunk in sequence, a wait, an ended, or the result, which comes last. // The ended line is additive to spec §5.5's list ("from here every outcome // is a line in that body"): it lets the CLI tell nobody picking the read // (DBF-3) from a read that did not finish (DBF-12), which a console restart // or a dropped connection also ends with no result. type Line struct { Admitted string `json:"admitted,omitempty"` Picked string `json:"picked,omitempty"` Chunk int64 `json:"chunk,omitempty"` Data []byte `json:"data,omitempty"` Wait string `json:"wait,omitempty"` Ended string `json:"ended,omitempty"` Result *Result `json:"result,omitempty"` } // ReadBody is the POST …/db/{host}/reads body (spec §5.5 step 2). type ReadBody struct { Op string `json:"op"` SQL string `json:"sql"` At string `json:"at"` ReplyKey string `json:"reply_key"` }