Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Stream: add total #92

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

arvidj
Copy link
Collaborator

@arvidj arvidj commented Oct 10, 2023

This code shouldn't be merged. However, posting it to get some comments. For a given use case, I needed to know the total number of items for a given paginated stream, without requesting all items in the stream (being very long). The ugly thing about the hack to this end in this PR is that you have to get the first element of the stream (by calling Stream.next) before Stream.total becomes available.

Nicer solutions could be:

  • Having Stream.total force the stream
  • Changing the type of Stream.t so that the user has to provide a function that returns the total number of elements in the stream. When creating a Stream.t from GitLab API requests, this function can do e.g. an HTTP HEAD on the API endpoint to get the total number.

Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant