Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatCursor ¶
func FormatCursor(idx int) networkid.PaginationCursor
func IndexAtOrAfter ¶
IndexAtOrAfter returns the first index i in [0, n) where getTime(i) >= anchor, using binary search. Returns 0 if anchor is zero.
func NextStreamOrder ¶
NextStreamOrder computes a monotonically increasing stream order value derived from a timestamp. If the timestamp-based order would not exceed last, it returns last+1 to guarantee strict ordering.
func ParseCursor ¶
func ParseCursor(cursor networkid.PaginationCursor) (int, bool)
Types ¶
type PaginateParams ¶
type PaginateParams struct {
Count int
Forward bool
Cursor networkid.PaginationCursor
AnchorMessage *database.Message
ForwardAnchorShift int // added to anchor index in forward mode (e.g. 1 to start after anchor)
}
PaginateParams controls how a slice of backfill entries is paginated. Cursor is only used for backward pagination (Forward == false).
type PaginateResult ¶
type PaginateResult struct {
Start, End int
Cursor networkid.PaginationCursor
HasMore bool
}
PaginateResult describes the selected window within the full entry slice.
func Paginate ¶
func Paginate( totalLen int, params PaginateParams, findAnchor func(*database.Message) (int, bool), indexAtOrAfter func(*database.Message) int, ) PaginateResult
Paginate selects a window of entries from a sorted slice using cursor/anchor-based pagination.
findAnchor returns the index of the anchor message within the entries (and true), or false if not found. indexAtOrAfter returns the first index whose timestamp is >= the anchor time.