Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PubSub: Deprecate several FlowControl settings and things in Message class #8796

Merged
merged 3 commits into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pubsub/google/cloud/pubsub_v1/subscriber/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import json
import math
import time
import warnings

from google.api_core import datetime_helpers
from google.cloud.pubsub_v1.subscriber._protocol import requests
Expand Down Expand Up @@ -88,6 +89,10 @@ def __init__(self, message, ack_id, request_queue, autolease=True):
autolease (bool): An optional flag determining whether a new Message
instance should automatically lease itself upon creation.
Defaults to :data:`True`.

.. note::
.. deprecated:: 0.44.0
Parameter will be removed in future versions.
"""
self._message = message
self._ack_id = ack_id
Expand Down Expand Up @@ -216,7 +221,14 @@ def lease(self):
never need to call it manually, unless the
:class:`~.pubsub_v1.subscriber.message.Message` instance was
created with ``autolease=False``.

.. deprecated:: 0.44.0
Will be removed in future versions.
"""
warnings.warn(
"lease() is deprecated since 0.44.0, and will be removed in future versions.",
category=DeprecationWarning,
)
self._request_queue.put(
requests.LeaseRequest(ack_id=self._ack_id, byte_size=self.size)
)
Expand Down
45 changes: 34 additions & 11 deletions pubsub/google/cloud/pubsub_v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from __future__ import absolute_import
import collections
import sys
import textwrap

from google.api import http_pb2
from google.iam.v1 import iam_policy_pb2
Expand Down Expand Up @@ -100,19 +101,41 @@
"The maximum number of received - but not yet processed - messages before "
"pausing the message stream."
)
FlowControl.resume_threshold.__doc__ = (
"The relative threshold of the ``max_bytes`` and ``max_messages`` limits "
"below which to resume the message stream. Must be a positive number not "
"greater than ``1.0``."
FlowControl.resume_threshold.__doc__ = textwrap.dedent(
"""
The relative threshold of the ``max_bytes`` and ``max_messages`` limits
below which to resume the message stream. Must be a positive number not
greater than ``1.0``.

.. note::
.. deprecated:: 0.44.0
Will be removed in future versions."""
)
FlowControl.max_requests.__doc__ = "Currently not in use."
FlowControl.max_request_batch_size.__doc__ = (
"The maximum number of requests scheduled by callbacks to process and "
"dispatch at a time."
FlowControl.max_requests.__doc__ = textwrap.dedent(
"""
Currently not in use.

.. note::
.. deprecated:: 0.44.0
Will be removed in future versions."""
)
FlowControl.max_request_batch_size.__doc__ = textwrap.dedent(
"""
The maximum number of requests scheduled by callbacks to process and
dispatch at a time.

.. note::
.. deprecated:: 0.44.0
Will be removed in future versions."""
)
FlowControl.max_request_batch_latency.__doc__ = (
"The maximum amount of time in seconds to wait for additional request "
"items before processing the next batch of requests."
FlowControl.max_request_batch_latency.__doc__ = textwrap.dedent(
"""
The maximum amount of time in seconds to wait for additional request
items before processing the next batch of requests.

.. note::
.. deprecated:: 0.44.0
Will be removed in future versions."""
)
FlowControl.max_lease_duration.__doc__ = (
"The maximum amount of time in seconds to hold a lease on a message "
Expand Down
5 changes: 4 additions & 1 deletion pubsub/tests/unit/pubsub_v1/subscriber/test_message.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import time

import mock
import pytest
import pytz
from six.moves import queue
from google.protobuf import timestamp_pb2
Expand Down Expand Up @@ -135,7 +136,9 @@ def test_drop():

def test_lease():
msg = create_message(b"foo", ack_id="bogus_ack_id")
with mock.patch.object(msg._request_queue, "put") as put:

pytest_warns = pytest.warns(DeprecationWarning)
with pytest_warns, mock.patch.object(msg._request_queue, "put") as put:
msg.lease()
put.assert_called_once_with(
requests.LeaseRequest(ack_id="bogus_ack_id", byte_size=30)
tseaver marked this conversation as resolved.
Show resolved Hide resolved
Expand Down