Documentation
¶
Overview ¶
Package cursor provides a unified cursor encoding/decoding utility for pagination. Cursors are versioned and resource-scoped, allowing different parts of the system to use cursors without collision.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidCursor indicates the cursor is malformed or cannot be decoded. ErrInvalidCursor = errors.New("invalid cursor") // ErrVersionMismatch indicates the cursor version doesn't match the expected version. ErrVersionMismatch = errors.New("cursor version mismatch") )
Functions ¶
func Base62Decode ¶
Base62Decode decodes a base62 string.
func Decode ¶
Decode decodes and validates a cursor string. Returns the data portion if the cursor matches the expected resource and version. Returns ErrInvalidCursor if the cursor is malformed. Returns an error wrapping both ErrInvalidCursor and ErrVersionMismatch if the version doesn't match.
func Encode ¶
Encode creates a versioned cursor string. Format: {resource}v{version:02d}:{data}, then base62 encoded. Example: "evtv01:position_data" -> base62
func ParseTimeMs ¶ added in v1.6.0
ParseTimeMs reads the unix milliseconds timestamp of a cursor position. The error wraps ErrInvalidCursor.
Types ¶
This section is empty.