Skip to content

Commit

Permalink
feat: publish RateLimitInfo and FeatureFlag protos (#768)
Browse files Browse the repository at this point in the history
* feat: publish RateLimitInfo and FeatureFlag protos

PiperOrigin-RevId: 527878708

Source-Link: googleapis/googleapis@f129f48

Source-Link: googleapis/googleapis-gen@e02c87d
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTAyYzg3ZDlkMGM5YTc3ZjJiMTcyNjhhODZmNDYyYjVhMWQ2NmJiZCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* fix: Add feature flag proto to BUILD file

PiperOrigin-RevId: 528468347

Source-Link: googleapis/googleapis@38247e8

Source-Link: googleapis/googleapis-gen@17e62a1
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMTdlNjJhMWFiNWYyMmQ3ZDUzNzY3NWE2NTkxNTcyMDdlNDA2ZTYzZCJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
gcf-owl-bot[bot] and gcf-owl-bot[bot] authored May 4, 2023
1 parent b5d10d6 commit 171fea6
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 6 deletions.
4 changes: 4 additions & 0 deletions google/cloud/bigtable_v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from .types.bigtable import MutateRowsResponse
from .types.bigtable import PingAndWarmRequest
from .types.bigtable import PingAndWarmResponse
from .types.bigtable import RateLimitInfo
from .types.bigtable import ReadChangeStreamRequest
from .types.bigtable import ReadChangeStreamResponse
from .types.bigtable import ReadModifyWriteRowRequest
Expand All @@ -54,6 +55,7 @@
from .types.data import StreamPartition
from .types.data import TimestampRange
from .types.data import ValueRange
from .types.feature_flags import FeatureFlags
from .types.request_stats import FullReadStatsView
from .types.request_stats import ReadIterationStats
from .types.request_stats import RequestLatencyStats
Expand All @@ -69,6 +71,7 @@
"Column",
"ColumnRange",
"Family",
"FeatureFlags",
"FullReadStatsView",
"GenerateInitialChangeStreamPartitionsRequest",
"GenerateInitialChangeStreamPartitionsResponse",
Expand All @@ -79,6 +82,7 @@
"Mutation",
"PingAndWarmRequest",
"PingAndWarmResponse",
"RateLimitInfo",
"ReadChangeStreamRequest",
"ReadChangeStreamResponse",
"ReadIterationStats",
Expand Down
6 changes: 4 additions & 2 deletions google/cloud/bigtable_v2/services/bigtable/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,10 @@ def read_rows(
on the ``request`` instance; if ``request`` is provided, this
should not be set.
app_profile_id (:class:`str`):
This value specifies routing for replication. This API
only accepts the empty value of app_profile_id.
This value specifies routing for
replication. If not specified, the
"default" application profile will be
used.
This corresponds to the ``app_profile_id`` field
on the ``request`` instance; if ``request`` is provided, this
Expand Down
6 changes: 4 additions & 2 deletions google/cloud/bigtable_v2/services/bigtable/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,8 +491,10 @@ def read_rows(
on the ``request`` instance; if ``request`` is provided, this
should not be set.
app_profile_id (str):
This value specifies routing for replication. This API
only accepts the empty value of app_profile_id.
This value specifies routing for
replication. If not specified, the
"default" application profile will be
used.
This corresponds to the ``app_profile_id`` field
on the ``request`` instance; if ``request`` is provided, this
Expand Down
6 changes: 6 additions & 0 deletions google/cloud/bigtable_v2/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
MutateRowsResponse,
PingAndWarmRequest,
PingAndWarmResponse,
RateLimitInfo,
ReadChangeStreamRequest,
ReadChangeStreamResponse,
ReadModifyWriteRowRequest,
Expand All @@ -50,6 +51,9 @@
TimestampRange,
ValueRange,
)
from .feature_flags import (
FeatureFlags,
)
from .request_stats import (
FullReadStatsView,
ReadIterationStats,
Expand All @@ -71,6 +75,7 @@
"MutateRowsResponse",
"PingAndWarmRequest",
"PingAndWarmResponse",
"RateLimitInfo",
"ReadChangeStreamRequest",
"ReadChangeStreamResponse",
"ReadModifyWriteRowRequest",
Expand All @@ -94,6 +99,7 @@
"StreamPartition",
"TimestampRange",
"ValueRange",
"FeatureFlags",
"FullReadStatsView",
"ReadIterationStats",
"RequestLatencyStats",
Expand Down
59 changes: 57 additions & 2 deletions google/cloud/bigtable_v2/types/bigtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"MutateRowResponse",
"MutateRowsRequest",
"MutateRowsResponse",
"RateLimitInfo",
"CheckAndMutateRowRequest",
"CheckAndMutateRowResponse",
"PingAndWarmRequest",
Expand All @@ -61,8 +62,9 @@ class ReadRowsRequest(proto.Message):
Values are of the form
``projects/<project>/instances/<instance>/tables/<table>``.
app_profile_id (str):
This value specifies routing for replication. This API only
accepts the empty value of app_profile_id.
This value specifies routing for replication.
If not specified, the "default" application
profile will be used.
rows (google.cloud.bigtable_v2.types.RowSet):
The row keys and/or ranges to read
sequentially. If not specified, reads from all
Expand Down Expand Up @@ -469,10 +471,19 @@ class Entry(proto.Message):
class MutateRowsResponse(proto.Message):
r"""Response message for BigtableService.MutateRows.
.. _oneof: https://proto-plus-python.readthedocs.io/en/stable/fields.html#oneofs-mutually-exclusive-fields
Attributes:
entries (MutableSequence[google.cloud.bigtable_v2.types.MutateRowsResponse.Entry]):
One or more results for Entries from the
batch request.
rate_limit_info (google.cloud.bigtable_v2.types.RateLimitInfo):
Information about how client should limit the
rate (QPS). Primirily used by supported official
Cloud Bigtable clients. If unset, the rate limit
info is not provided by the server.
This field is a member of `oneof`_ ``_rate_limit_info``.
"""

class Entry(proto.Message):
Expand Down Expand Up @@ -506,6 +517,50 @@ class Entry(proto.Message):
number=1,
message=Entry,
)
rate_limit_info: "RateLimitInfo" = proto.Field(
proto.MESSAGE,
number=3,
optional=True,
message="RateLimitInfo",
)


class RateLimitInfo(proto.Message):
r"""Information about how client should adjust the load to
Bigtable.
Attributes:
period (google.protobuf.duration_pb2.Duration):
Time that clients should wait before
adjusting the target rate again. If clients
adjust rate too frequently, the impact of the
previous adjustment may not have been taken into
account and may over-throttle or under-throttle.
If clients adjust rate too slowly, they will not
be responsive to load changes on server side,
and may over-throttle or under-throttle.
factor (float):
If it has been at least one ``period`` since the last load
adjustment, the client should multiply the current load by
this value to get the new target load. For example, if the
current load is 100 and ``factor`` is 0.8, the new target
load should be 80. After adjusting, the client should ignore
``factor`` until another ``period`` has passed.
The client can measure its load using any unit that's
comparable over time For example, QPS can be used as long as
each request involves a similar amount of work.
"""

period: duration_pb2.Duration = proto.Field(
proto.MESSAGE,
number=1,
message=duration_pb2.Duration,
)
factor: float = proto.Field(
proto.DOUBLE,
number=2,
)


class CheckAndMutateRowRequest(proto.Message):
Expand Down
54 changes: 54 additions & 0 deletions google/cloud/bigtable_v2/types/feature_flags.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*-
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from __future__ import annotations

from typing import MutableMapping, MutableSequence

import proto # type: ignore


__protobuf__ = proto.module(
package="google.bigtable.v2",
manifest={
"FeatureFlags",
},
)


class FeatureFlags(proto.Message):
r"""Feature flags supported by a client. This is intended to be sent as
part of request metadata to assure the server that certain behaviors
are safe to enable. This proto is meant to be serialized and
websafe-base64 encoded under the ``bigtable-features`` metadata key.
The value will remain constant for the lifetime of a client and due
to HTTP2's HPACK compression, the request overhead will be tiny.
This is an internal implementation detail and should not be used by
endusers directly.
Attributes:
mutate_rows_rate_limit (bool):
Notify the server that the client enables
batch write flow control by requesting
RateLimitInfo from MutateRowsResponse.
"""

mutate_rows_rate_limit: bool = proto.Field(
proto.BOOL,
number=3,
)


__all__ = tuple(sorted(__protobuf__.manifest))

0 comments on commit 171fea6

Please sign in to comment.