Best way to indicate more results available
Posted
by
Alex Stangl
on Programmers
See other posts from Programmers
or by Alex Stangl
Published on 2014-04-23T02:46:43Z
Indexed on
2014/08/21
10:29 UTC
Read the original article
Hit count: 364
We have a service to return messages. We want to limit the number returned, either allowing the caller to specify the max number to return, or else to use an internal hard limit. We also have thought it would be nice to include in the response whether more messages are available. The "best" way to go about this is not clear.
Here are some ideas so far:
- Only set the "more messages" indicator if the user did not specify a max limit, and the internal max limit was hit.
- Same as #1 except that "more messages" indicator set regardless of whether the internal hard limit is hit, or the user-specified limit is hit.
- Same as #1 (or #2) except that we internally read limit + 1 records, but only return limit records, so we know "for sure" there is at least one additional message rather than "maybe" there are additional messages.
- Do away with the "more messages" flag, as it is confusing and unnecessary. Instead force the user to keep calling the API until it returns no messages.
- Change "more messages" indicator to something more akin to an EOF indicator, only set when the last message is known to have been retrieved and returned.
What do you think is the best solution? (Doesn't have to be one of the above choices.) I searched and couldn't find a similar question already asked. Hopefully this is not "too subjective".
© Programmers or respective owner