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

feat: add max_commit_delay API #1078

Merged
merged 5 commits into from Jan 18, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions google/cloud/spanner_v1/types/spanner.py
Expand Up @@ -24,6 +24,7 @@
from google.cloud.spanner_v1.types import result_set
from google.cloud.spanner_v1.types import transaction as gs_transaction
from google.cloud.spanner_v1.types import type as gs_type
from google.protobuf import duration_pb2 # type: ignore
from google.protobuf import struct_pb2 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
from google.rpc import status_pb2 # type: ignore
Expand Down Expand Up @@ -1434,6 +1435,14 @@ class CommitRequest(proto.Message):
be included in the
[CommitResponse][google.spanner.v1.CommitResponse.commit_stats].
Default value is ``false``.
max_commit_delay (google.protobuf.duration_pb2.Duration):
Optional. The amount of latency this request
is willing to incur in order to improve
throughput. If this field is not set, Spanner
assumes requests are relatively latency
sensitive and automatically determines an
appropriate delay time. You can specify a
batching delay value between 0 and 500 ms.
request_options (google.cloud.spanner_v1.types.RequestOptions):
Common options for this request.
"""
Expand Down Expand Up @@ -1462,6 +1471,11 @@ class CommitRequest(proto.Message):
proto.BOOL,
number=5,
)
max_commit_delay: duration_pb2.Duration = proto.Field(
proto.MESSAGE,
number=8,
message=duration_pb2.Duration,
)
request_options: "RequestOptions" = proto.Field(
proto.MESSAGE,
number=6,
Expand Down
18 changes: 18 additions & 0 deletions google/cloud/spanner_v1/types/type.py
Expand Up @@ -94,6 +94,11 @@ class TypeCode(proto.Enum):
- Members of a JSON object are not guaranteed to have their
order preserved.
- JSON array elements will have their order preserved.
PROTO (13):
Encoded as a base64-encoded ``string``, as described in RFC
4648, section 4.
ENUM (14):
Encoded as ``string``, in decimal format.
"""
TYPE_CODE_UNSPECIFIED = 0
BOOL = 1
Expand All @@ -107,6 +112,8 @@ class TypeCode(proto.Enum):
STRUCT = 9
NUMERIC = 10
JSON = 11
PROTO = 13
ENUM = 14


class TypeAnnotationCode(proto.Enum):
Expand Down Expand Up @@ -179,6 +186,13 @@ class Type(proto.Message):
typically is not needed to process the content of a value
(it doesn't affect serialization) and clients can ignore it
on the read path.
proto_type_fqn (str):
If [code][google.spanner.v1.Type.code] ==
[PROTO][google.spanner.v1.TypeCode.PROTO] or
[code][google.spanner.v1.Type.code] ==
[ENUM][google.spanner.v1.TypeCode.ENUM], then
``proto_type_fqn`` is the fully qualified name of the proto
type representing the proto/enum definition.
"""

code: "TypeCode" = proto.Field(
Expand All @@ -201,6 +215,10 @@ class Type(proto.Message):
number=4,
enum="TypeAnnotationCode",
)
proto_type_fqn: str = proto.Field(
proto.STRING,
number=5,
)


class StructType(proto.Message):
Expand Down
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-spanner-admin-database",
"version": "3.41.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-spanner-admin-instance",
"version": "3.41.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
Expand Up @@ -8,7 +8,7 @@
],
"language": "PYTHON",
"name": "google-cloud-spanner",
"version": "3.41.0"
"version": "0.1.0"
},
"snippets": [
{
Expand Down
2 changes: 1 addition & 1 deletion scripts/fixup_spanner_v1_keywords.py
Expand Up @@ -42,7 +42,7 @@ class spannerCallTransformer(cst.CSTTransformer):
'batch_create_sessions': ('database', 'session_count', 'session_template', ),
'batch_write': ('session', 'mutation_groups', 'request_options', ),
'begin_transaction': ('session', 'options', 'request_options', ),
'commit': ('session', 'transaction_id', 'single_use_transaction', 'mutations', 'return_commit_stats', 'request_options', ),
'commit': ('session', 'transaction_id', 'single_use_transaction', 'mutations', 'return_commit_stats', 'max_commit_delay', 'request_options', ),
'create_session': ('database', 'session', ),
'delete_session': ('name', ),
'execute_batch_dml': ('session', 'transaction', 'statements', 'seqno', 'request_options', ),
Expand Down