Add pubsub subscriber leaser#5210
Conversation
This is another helper thread that maintains the leases for any messages that the current subscriber is working on. The majority of this code (notably, `maintain_leases`) is copied from `pubsub_v1.subscriber.policy.base.BasePolicy.maintain_leases`.
| self._subscriber.drop(to_drop) | ||
|
|
||
| # Remove dropped items from our copy of the leased messages (they | ||
| # have already been removed from the real one by self.drop). |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
|
||
| # Remove dropped items from our copy of the leased messages (they | ||
| # have already been removed from the real one by self.drop). | ||
| for item in to_drop: |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| # Create a streaming pull request. | ||
| # We do not actually call `modify_ack_deadline` over and over | ||
| # because it is more efficient to make a single request. | ||
| ack_ids = list(leased_messages.keys()) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| # period between 0 seconds and 90% of the lease. This use of | ||
| # jitter (http://bit.ly/2s2ekL7) helps decrease contention in cases | ||
| # where there are many clients. | ||
| snooze = random.uniform(0.0, p99 * 0.9) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| leaser_ = leaser.Leaser(mock.sentinel.subscriber) | ||
|
|
||
| leaser_.add([ | ||
| requests.LeaseRequest(ack_id='ack1', byte_size=50)]) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This is another helper thread that maintains the leases for any messages that the current subscriber is working on. The majority of this code (notably, `maintain_leases`) is copied from `pubsub_v1.subscriber.policy.base.BasePolicy.maintain_leases`.
This is another helper thread that maintains the leases for any messages that the current subscriber is working on. The majority of this code (notably,
maintain_leases) is copied frompubsub_v1.subscriber.policy.base.BasePolicy.maintain_leases.