Skip to content

Commit

Permalink
feat: Add support for Cloud Bigtable Request Priorities in App Profil…
Browse files Browse the repository at this point in the history
…es (#871)

* feat: Add support for Cloud Bigtable Request Priorities in App Profiles

PiperOrigin-RevId: 571158646

Source-Link: googleapis/googleapis@bc3c83b

Source-Link: googleapis/googleapis-gen@93366e8
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiOTMzNjZlODRlNGU2ODYxZTJlNTgwZWIwMDA3MjFkOTliZjU0YTBhNCJ9

* 🦉 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 Oct 7, 2023
1 parent e5af359 commit a4d551e
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
65 changes: 64 additions & 1 deletion google/cloud/bigtable_admin_v2/types/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class AutoscalingTargets(proto.Message):
The storage utilization that the Autoscaler should be trying
to achieve. This number is limited between 2560 (2.5TiB) and
5120 (5TiB) for a SSD cluster and between 8192 (8TiB) and
16384 (16TiB) for an HDD cluster; otherwise it will return
16384 (16TiB) for an HDD cluster, otherwise it will return
INVALID_ARGUMENT error. If this value is set to 0, it will
be treated as if it were set to the default value: 2560 for
SSD, 8192 for HDD.
Expand Down Expand Up @@ -419,8 +419,43 @@ class AppProfile(proto.Message):
Use a single-cluster routing policy.
This field is a member of `oneof`_ ``routing_policy``.
priority (google.cloud.bigtable_admin_v2.types.AppProfile.Priority):
This field has been deprecated in favor of
``standard_isolation.priority``. If you set this field,
``standard_isolation.priority`` will be set instead.
The priority of requests sent using this app profile.
This field is a member of `oneof`_ ``isolation``.
standard_isolation (google.cloud.bigtable_admin_v2.types.AppProfile.StandardIsolation):
The standard options used for isolating this
app profile's traffic from other use cases.
This field is a member of `oneof`_ ``isolation``.
"""

class Priority(proto.Enum):
r"""Possible priorities for an app profile. Note that higher
priority writes can sometimes queue behind lower priority writes
to the same tablet, as writes must be strictly sequenced in the
durability log.
Values:
PRIORITY_UNSPECIFIED (0):
Default value. Mapped to PRIORITY_HIGH (the legacy behavior)
on creation.
PRIORITY_LOW (1):
No description available.
PRIORITY_MEDIUM (2):
No description available.
PRIORITY_HIGH (3):
No description available.
"""
PRIORITY_UNSPECIFIED = 0
PRIORITY_LOW = 1
PRIORITY_MEDIUM = 2
PRIORITY_HIGH = 3

class MultiClusterRoutingUseAny(proto.Message):
r"""Read/write requests are routed to the nearest cluster in the
instance, and will fail over to the nearest cluster that is
Expand Down Expand Up @@ -466,6 +501,22 @@ class SingleClusterRouting(proto.Message):
number=2,
)

class StandardIsolation(proto.Message):
r"""Standard options for isolating this app profile's traffic
from other use cases.
Attributes:
priority (google.cloud.bigtable_admin_v2.types.AppProfile.Priority):
The priority of requests sent using this app
profile.
"""

priority: "AppProfile.Priority" = proto.Field(
proto.ENUM,
number=1,
enum="AppProfile.Priority",
)

name: str = proto.Field(
proto.STRING,
number=1,
Expand All @@ -490,6 +541,18 @@ class SingleClusterRouting(proto.Message):
oneof="routing_policy",
message=SingleClusterRouting,
)
priority: Priority = proto.Field(
proto.ENUM,
number=7,
oneof="isolation",
enum=Priority,
)
standard_isolation: StandardIsolation = proto.Field(
proto.MESSAGE,
number=11,
oneof="isolation",
message=StandardIsolation,
)


class HotTablet(proto.Message):
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/gapic/bigtable_admin_v2/test_bigtable_instance_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3524,6 +3524,7 @@ def test_create_app_profile(request_type, transport: str = "grpc"):
name="name_value",
etag="etag_value",
description="description_value",
priority=instance.AppProfile.Priority.PRIORITY_LOW,
)
response = client.create_app_profile(request)

Expand Down Expand Up @@ -3793,6 +3794,7 @@ def test_get_app_profile(request_type, transport: str = "grpc"):
name="name_value",
etag="etag_value",
description="description_value",
priority=instance.AppProfile.Priority.PRIORITY_LOW,
)
response = client.get_app_profile(request)

Expand Down Expand Up @@ -9323,6 +9325,8 @@ def test_create_app_profile_rest(request_type):
"cluster_id": "cluster_id_value",
"allow_transactional_writes": True,
},
"priority": 1,
"standard_isolation": {"priority": 1},
}
request = request_type(**request_init)

Expand All @@ -9333,6 +9337,7 @@ def test_create_app_profile_rest(request_type):
name="name_value",
etag="etag_value",
description="description_value",
priority=instance.AppProfile.Priority.PRIORITY_LOW,
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -9550,6 +9555,8 @@ def test_create_app_profile_rest_bad_request(
"cluster_id": "cluster_id_value",
"allow_transactional_writes": True,
},
"priority": 1,
"standard_isolation": {"priority": 1},
}
request = request_type(**request_init)

Expand Down Expand Up @@ -9655,6 +9662,7 @@ def test_get_app_profile_rest(request_type):
name="name_value",
etag="etag_value",
description="description_value",
priority=instance.AppProfile.Priority.PRIORITY_LOW,
)

# Wrap the value into a proper Response obj
Expand Down Expand Up @@ -10283,6 +10291,8 @@ def test_update_app_profile_rest(request_type):
"cluster_id": "cluster_id_value",
"allow_transactional_writes": True,
},
"priority": 1,
"standard_isolation": {"priority": 1},
}
request = request_type(**request_init)

Expand Down Expand Up @@ -10489,6 +10499,8 @@ def test_update_app_profile_rest_bad_request(
"cluster_id": "cluster_id_value",
"allow_transactional_writes": True,
},
"priority": 1,
"standard_isolation": {"priority": 1},
}
request = request_type(**request_init)

Expand Down

0 comments on commit a4d551e

Please sign in to comment.