<div dir="ltr"><div style="font-size:12.8px">Hello Telemetry Team,</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I see that the Panko API does not provide a way to go through all events in the order they were stored in database. Panko sorts events by generated and message_id fields and uses message_id field as a marker for pagination. So, the following case is possible:</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Before the first request we had the following events in database:</div><div style="font-size:12.8px">+-------------------+---------<wbr>---------------------+</div><div style="font-size:12.8px">|| message_id1 | 2017-08-29T00:05.00 ||</div><div style="font-size:12.8px">+-------------------+---------<wbr>---------------------+</div><div style="font-size:12.8px">|| message_id2 | 2017-08-29T00:06.00 ||</div><div style="font-size:12.8px">+-------------------+---------<wbr>---------------------+</div><div style="font-size:12.8px">|| message_id3 | 2017-08-29T00:08.00 ||</div><div style="font-size:12.8px">+-------------------+---------<wbr>---------------------+</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">During the first request we got all three events:</div><div style="font-size:12.8px">GET /v2/events?limit=3 </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">After the request some new events were added:</div><div style="font-size:12.8px">+-------------------+---------<wbr>---------------------+</div><div style="font-size:12.8px">|| message_id1 | 2017-08-29T00:05.00 ||</div><div style="font-size:12.8px">+-------------------+---------<wbr>---------------------+</div><div style="font-size:12.8px">|| message_id2 | 2017-08-29T00:06.00 ||</div><div style="font-size:12.8px">+-------------------+---------<wbr>---------------------+</div><div style="font-size:12.8px">|| message_id4 | 2017-08-29T00:07.00 ||</div><div style="font-size:12.8px">+-------------------+---------<wbr>---------------------+</div><div style="font-size:12.8px">|| message_id3 | 2017-08-29T00:08.00 ||</div><div style="font-size:12.8px">+-------------------+---------<wbr>---------------------+</div><div style="font-size:12.8px">|| message_id5 | 2017-08-29T00:09.00 ||</div><div style="font-size:12.8px">+-------------------+---------<wbr>---------------------+</div><div style="font-size:12.8px">|| message_id6 | 2017-08-29T00:09.00 ||</div><div style="font-size:12.8px">+-------------------+---------<wbr>---------------------+</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">To proceed next we set marker to message_id3:</div><div style="font-size:12.8px">GET /v2/events?marker=message_id3&<wbr>limit=3</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">In this case we will get only two new events (message_id5, message_id6). To get message_id4 we need to make the first request again. </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">That all makes difficult such scenarios when API clients need to process events as they appear in database.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I'd like to discuss how we can extend the current API to provide a way to go through all events in the order they were stored in database.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">It looks like cursor API might be useful in this case. We can introduce new "cursor" query parameter. It will work as a marker for pagination, but will determine "special" sorting of events. In this case the request might look like:</div><div style="font-size:12.8px">GET /v2/events?cursor=-1&limit=100</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">The response will return a list of events and next cursor:</div><div style="font-size:12.8px">{</div><div style="font-size:12.8px">    events: []</div><div style="font-size:12.8px">    next_cursor: 12345</div><div style="font-size:12.8px">} </div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">So, a request to get the next portion of events will look like:</div><div style="font-size:12.8px">GET /v2/events?cursor=12345&limit=<wbr>100</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">I will be glad to hear your comments, suggestions.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Thanks,</div><div style="font-size:12.8px">Mike</div></div>