ds_protocol_http_py_lib.dataset.pagination.strategies.base ========================================================== .. py:module:: ds_protocol_http_py_lib.dataset.pagination.strategies.base .. autoapi-nested-parse:: **File:** ``base.py`` **Region:** ``ds_protocol_http_py_lib/dataset/pagination/strategies/base`` Base ABC for registered pagination strategies (page-variation hooks only). Concrete strategies (offset, page-number, cursor, …) inherit this. The HTTP drain loop lives on :class:`~dataset.pagination.paginate.Paginate`, which *uses* a strategy — strategies do not own ``run``. Attributes ---------- .. autoapisummary:: ds_protocol_http_py_lib.dataset.pagination.strategies.base.ConfigT Classes ------- .. autoapisummary:: ds_protocol_http_py_lib.dataset.pagination.strategies.base.PageState ds_protocol_http_py_lib.dataset.pagination.strategies.base.PaginationStrategyHandler Functions --------- .. autoapisummary:: ds_protocol_http_py_lib.dataset.pagination.strategies.base.is_short_or_empty_page Module Contents --------------- .. py:data:: ConfigT .. py:class:: PageState Strategy-owned traversal state for one paginated read. .. py:attribute:: values :type: dict[str, Any] Opaque strategy values (offset, page, cursor, …). .. py:attribute:: page_index :type: int :value: 0 Zero-based count of pages fetched so far. .. py:class:: PaginationStrategyHandler Bases: :py:obj:`abc.ABC`, :py:obj:`Generic`\ [\ :py:obj:`ConfigT`\ ] Page-variation contract parameterized by the strategy settings nest. Each concrete strategy binds ``ConfigT`` to its nest type (e.g. ``CursorPaginationSettings``) so hook signatures stay precise. .. py:method:: initial_state(cfg: ConfigT, checkpoint_slice: dict[str, Any] | None) -> PageState :abstractmethod: Build the starting page state, optionally restoring from checkpoint. .. py:method:: inject(request: ds_protocol_http_py_lib.utils.http.request.RequestSnapshot, state: PageState, cfg: ConfigT) -> ds_protocol_http_py_lib.utils.http.request.RequestSnapshot :abstractmethod: Return a request snapshot with pagination values applied. .. py:method:: advance(*, body: Any, headers: Any, items: list[Any], state: PageState, cfg: ConfigT) -> PageState :abstractmethod: Advance state after a successful page response. .. py:method:: should_stop(*, body: Any, headers: Any, items: list[Any], state: PageState, cfg: ConfigT) -> bool :abstractmethod: Return True when traversal should terminate after this page. .. py:method:: to_checkpoint(state: PageState) -> dict[str, Any] :abstractmethod: Serialize traversal state into the checkpoint ``pagination`` slice. .. py:method:: from_checkpoint(data: dict[str, Any]) -> PageState :abstractmethod: Restore traversal state from a checkpoint ``pagination`` slice. .. py:function:: is_short_or_empty_page(items: list[Any], page_size: int) -> bool True when the page is empty or shorter than the requested page size.