Skip to content

GitLab

  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • hgitaly hgitaly
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 40
    • Issues 40
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 2
    • Merge requests 2
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • heptapod
  • hgitalyhgitaly
  • Issues
  • #92

Closed
Open
Created Mar 01, 2022 by Georges Racinet@gracinet🦑Owner

Helper for pagination conventions of streaming RPCs

The general convention for streamed responses with the pagination protocol is that the PaginationCursor attribute must be set on the first response and only the first response. As seen in #91 (closed), an empty PaginationCursor is not what is expected there.

This is hard to get right because of this subtle difference between the Python and Ruby gRPC libraries.

Python gRPC

A missing message field is returned back as the empty message:

>>> resp = GetTreeEntriesResponse()
>>> resp.pagination_cursor is None
False
>>> resp.pagination_cursor == PaginationCursor()
True

Despite this, fortunately, there is still a difference in Python between not setting and setting an empty value

>>> resp.HasField('pagination_cursor')
False
>>> resp2 = GetTreeEntriesResponse(pagination_cursor=PaginationCursor())
>>> resp2.HasField('pagination_cursor')
True

Also not setting and setting None are equivalent (can be handy for code uniformity)

>>> resp3 = GetTreeEntriesResponse(pagination_cursor=None)
>>> resp3.HasField('pagination_cursor')
False

Ruby gRPC

A missing message is returned back as nil

[2] pry(main)> resp = Gitaly::GetTreeEntriesResponse.new()
=> <Gitaly::GetTreeEntriesResponse: entries: []>
[3] pry(main)> resp.pagination_cursor
=> nil
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Assignee
Assign to
Time tracking