def do_GET_readiness(self) -> None:
        """Handle a ``GET`` request to ``/readiness`` path.

            * Query parameters:

                * ``lag``: only accept replication lag up to ``lag``. Accepts either an :class:`int`, which
                    represents lag in bytes, or a :class:`str` representing lag in human-readable format (e.g.
                    ``10MB``).
                * ``mode``: allowed values ``write``, ``apply``. Base replication lag off of received WAL or
                    replayed WAL. Defaults to ``apply``.

        Write a simple HTTP response which HTTP status can be:

            * ``200``:

                * If this Patroni node considers itself the leader; or
                * If PostgreSQL is running, replicating and not lagging;

            * ``503``: if none of the previous conditions apply.

        """
        failure_reason = self._readiness()

        if failure_reason:
            logger.debug("Readiness check failure: %s", failure_reason)

        self._write_status_code_only(200 if not failure_reason else 503)
Handle a ``GET`` request to ``/readiness`` path.

            * Query parameters:

                * ``lag``: only accept replication lag up to ``lag``. Accepts either an :class:`int`, which
                    represents lag in bytes, or a :class:`str` representing lag in human-readable format (e.g.
                    ``10MB``).
                * ``mode``: allowed values ``write``, ``apply``. Base replication lag off of received WAL or
                    replayed WAL. Defaults to ``apply``.

        Write a simple HTTP response which HTTP status can be:

            * ``200``:

                * If this Patroni node considers itself the leader; or
                * If PostgreSQL is running, replicating and not lagging;

            * ``503``: if none of the previous conditions apply.

        
patroni/api.py