Skip to content

Commit

Permalink
chore: protos for R/W transaction support on multiplexed sessions
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 683879049

Source-Link: googleapis/googleapis@2b6b93b

Source-Link: googleapis/googleapis-gen@2f0c933
Copy-Tag: eyJwIjoiYXBpcy9Hb29nbGUuQ2xvdWQuU3Bhbm5lci5WMS8uT3dsQm90LnlhbWwiLCJoIjoiMmYwYzkzM2IwMDMxNjRkNWNkMTIwNTA1YTk4Yzg3Yzk1ODg4ZDk4ZiJ9
  • Loading branch information
gcf-owl-bot[bot] authored and jskeet committed Oct 9, 2024
1 parent df83180 commit 2c001a6
Show file tree
Hide file tree
Showing 10 changed files with 951 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public async Task BeginTransactionRequestObjectAsync()
SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
Options = new TransactionOptions(),
RequestOptions = new RequestOptions(),
MutationKey = new Mutation(),
};
// Make the request
Transaction response = await spannerClient.BeginTransactionAsync(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public void BeginTransactionRequestObject()
SessionAsSessionName = SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
Options = new TransactionOptions(),
RequestOptions = new RequestOptions(),
MutationKey = new Mutation(),
};
// Make the request
Transaction response = spannerClient.BeginTransaction(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public async Task CommitRequestObjectAsync()
ReturnCommitStats = false,
RequestOptions = new RequestOptions(),
MaxCommitDelay = new Duration(),
PrecommitToken = new MultiplexedSessionPrecommitToken(),
};
// Make the request
CommitResponse response = await spannerClient.CommitAsync(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void CommitRequestObject()
ReturnCommitStats = false,
RequestOptions = new RequestOptions(),
MaxCommitDelay = new Duration(),
PrecommitToken = new MultiplexedSessionPrecommitToken(),
};
// Make the request
CommitResponse response = spannerClient.Commit(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1915,12 +1915,12 @@
"segments": [
{
"start": 20,
"end": 46,
"end": 47,
"type": "FULL"
},
{
"start": 34,
"end": 44,
"end": 45,
"type": "SHORT"
}
]
Expand Down Expand Up @@ -1964,12 +1964,12 @@
"segments": [
{
"start": 20,
"end": 47,
"end": 48,
"type": "FULL"
},
{
"start": 35,
"end": 45,
"end": 46,
"type": "SHORT"
}
]
Expand Down Expand Up @@ -2218,12 +2218,12 @@
"segments": [
{
"start": 20,
"end": 51,
"end": 52,
"type": "FULL"
},
{
"start": 36,
"end": 49,
"end": 50,
"type": "SHORT"
}
]
Expand Down Expand Up @@ -2267,12 +2267,12 @@
"segments": [
{
"start": 20,
"end": 52,
"end": 53,
"type": "FULL"
},
{
"start": 37,
"end": 50,
"end": 51,
"type": "SHORT"
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ public void BeginTransactionRequestObject()
SessionAsSessionName = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
Options = new gcsv::TransactionOptions(),
RequestOptions = new gcsv::RequestOptions(),
MutationKey = new gcsv::Mutation(),
};
// Make the request
gcsv::Transaction response = spannerClient.BeginTransaction(request);
Expand All @@ -957,6 +958,7 @@ public async Task BeginTransactionRequestObjectAsync()
SessionAsSessionName = gcsv::SessionName.FromProjectInstanceDatabaseSession("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]"),
Options = new gcsv::TransactionOptions(),
RequestOptions = new gcsv::RequestOptions(),
MutationKey = new gcsv::Mutation(),
};
// Make the request
gcsv::Transaction response = await spannerClient.BeginTransactionAsync(request);
Expand Down Expand Up @@ -1039,6 +1041,7 @@ public void CommitRequestObject()
ReturnCommitStats = false,
RequestOptions = new gcsv::RequestOptions(),
MaxCommitDelay = new Duration(),
PrecommitToken = new gcsv::MultiplexedSessionPrecommitToken(),
};
// Make the request
gcsv::CommitResponse response = spannerClient.Commit(request);
Expand All @@ -1064,6 +1067,7 @@ public async Task CommitRequestObjectAsync()
ReturnCommitStats = false,
RequestOptions = new gcsv::RequestOptions(),
MaxCommitDelay = new Duration(),
PrecommitToken = new gcsv::MultiplexedSessionPrecommitToken(),
};
// Make the request
gcsv::CommitResponse response = await spannerClient.CommitAsync(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,22 @@ static CommitResponseReflection() {
string.Concat(
"Cidnb29nbGUvc3Bhbm5lci92MS9jb21taXRfcmVzcG9uc2UucHJvdG8SEWdv",
"b2dsZS5zcGFubmVyLnYxGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1wLnBy",
"b3RvIrIBCg5Db21taXRSZXNwb25zZRI0ChBjb21taXRfdGltZXN0YW1wGAEg",
"ASgLMhouZ29vZ2xlLnByb3RvYnVmLlRpbWVzdGFtcBJDCgxjb21taXRfc3Rh",
"dHMYAiABKAsyLS5nb29nbGUuc3Bhbm5lci52MS5Db21taXRSZXNwb25zZS5D",
"b21taXRTdGF0cxolCgtDb21taXRTdGF0cxIWCg5tdXRhdGlvbl9jb3VudBgB",
"IAEoA0K2AQoVY29tLmdvb2dsZS5zcGFubmVyLnYxQhNDb21taXRSZXNwb25z",
"ZVByb3RvUAFaNWNsb3VkLmdvb2dsZS5jb20vZ28vc3Bhbm5lci9hcGl2MS9z",
"cGFubmVycGI7c3Bhbm5lcnBiqgIXR29vZ2xlLkNsb3VkLlNwYW5uZXIuVjHK",
"AhdHb29nbGVcQ2xvdWRcU3Bhbm5lclxWMeoCGkdvb2dsZTo6Q2xvdWQ6OlNw",
"YW5uZXI6OlYxYgZwcm90bzM="));
"b3RvGiNnb29nbGUvc3Bhbm5lci92MS90cmFuc2FjdGlvbi5wcm90byKdAgoO",
"Q29tbWl0UmVzcG9uc2USNAoQY29tbWl0X3RpbWVzdGFtcBgBIAEoCzIaLmdv",
"b2dsZS5wcm90b2J1Zi5UaW1lc3RhbXASQwoMY29tbWl0X3N0YXRzGAIgASgL",
"Mi0uZ29vZ2xlLnNwYW5uZXIudjEuQ29tbWl0UmVzcG9uc2UuQ29tbWl0U3Rh",
"dHMSTgoPcHJlY29tbWl0X3Rva2VuGAQgASgLMjMuZ29vZ2xlLnNwYW5uZXIu",
"djEuTXVsdGlwbGV4ZWRTZXNzaW9uUHJlY29tbWl0VG9rZW5IABolCgtDb21t",
"aXRTdGF0cxIWCg5tdXRhdGlvbl9jb3VudBgBIAEoA0IZChdNdWx0aXBsZXhl",
"ZFNlc3Npb25SZXRyeUK2AQoVY29tLmdvb2dsZS5zcGFubmVyLnYxQhNDb21t",
"aXRSZXNwb25zZVByb3RvUAFaNWNsb3VkLmdvb2dsZS5jb20vZ28vc3Bhbm5l",
"ci9hcGl2MS9zcGFubmVycGI7c3Bhbm5lcnBiqgIXR29vZ2xlLkNsb3VkLlNw",
"YW5uZXIuVjHKAhdHb29nbGVcQ2xvdWRcU3Bhbm5lclxWMeoCGkdvb2dsZTo6",
"Q2xvdWQ6OlNwYW5uZXI6OlYxYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, },
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Cloud.Spanner.V1.TransactionReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Spanner.V1.CommitResponse), global::Google.Cloud.Spanner.V1.CommitResponse.Parser, new[]{ "CommitTimestamp", "CommitStats" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Spanner.V1.CommitResponse.Types.CommitStats), global::Google.Cloud.Spanner.V1.CommitResponse.Types.CommitStats.Parser, new[]{ "MutationCount" }, null, null, null, null)})
new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Spanner.V1.CommitResponse), global::Google.Cloud.Spanner.V1.CommitResponse.Parser, new[]{ "CommitTimestamp", "CommitStats", "PrecommitToken" }, new[]{ "MultiplexedSessionRetry" }, null, null, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Cloud.Spanner.V1.CommitResponse.Types.CommitStats), global::Google.Cloud.Spanner.V1.CommitResponse.Types.CommitStats.Parser, new[]{ "MutationCount" }, null, null, null, null)})
}));
}
#endregion
Expand Down Expand Up @@ -85,6 +88,12 @@ public CommitResponse() {
public CommitResponse(CommitResponse other) : this() {
commitTimestamp_ = other.commitTimestamp_ != null ? other.commitTimestamp_.Clone() : null;
commitStats_ = other.commitStats_ != null ? other.commitStats_.Clone() : null;
switch (other.MultiplexedSessionRetryCase) {
case MultiplexedSessionRetryOneofCase.PrecommitToken:
PrecommitToken = other.PrecommitToken.Clone();
break;
}

_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
}

Expand Down Expand Up @@ -126,6 +135,42 @@ public CommitResponse Clone() {
}
}

/// <summary>Field number for the "precommit_token" field.</summary>
public const int PrecommitTokenFieldNumber = 4;
/// <summary>
/// If specified, transaction has not committed yet.
/// Clients must retry the commit with the new precommit token.
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public global::Google.Cloud.Spanner.V1.MultiplexedSessionPrecommitToken PrecommitToken {
get { return multiplexedSessionRetryCase_ == MultiplexedSessionRetryOneofCase.PrecommitToken ? (global::Google.Cloud.Spanner.V1.MultiplexedSessionPrecommitToken) multiplexedSessionRetry_ : null; }
set {
multiplexedSessionRetry_ = value;
multiplexedSessionRetryCase_ = value == null ? MultiplexedSessionRetryOneofCase.None : MultiplexedSessionRetryOneofCase.PrecommitToken;
}
}

private object multiplexedSessionRetry_;
/// <summary>Enum of possible cases for the "MultiplexedSessionRetry" oneof.</summary>
public enum MultiplexedSessionRetryOneofCase {
None = 0,
PrecommitToken = 4,
}
private MultiplexedSessionRetryOneofCase multiplexedSessionRetryCase_ = MultiplexedSessionRetryOneofCase.None;
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public MultiplexedSessionRetryOneofCase MultiplexedSessionRetryCase {
get { return multiplexedSessionRetryCase_; }
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public void ClearMultiplexedSessionRetry() {
multiplexedSessionRetryCase_ = MultiplexedSessionRetryOneofCase.None;
multiplexedSessionRetry_ = null;
}

[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
public override bool Equals(object other) {
Expand All @@ -143,6 +188,8 @@ public bool Equals(CommitResponse other) {
}
if (!object.Equals(CommitTimestamp, other.CommitTimestamp)) return false;
if (!object.Equals(CommitStats, other.CommitStats)) return false;
if (!object.Equals(PrecommitToken, other.PrecommitToken)) return false;
if (MultiplexedSessionRetryCase != other.MultiplexedSessionRetryCase) return false;
return Equals(_unknownFields, other._unknownFields);
}

Expand All @@ -152,6 +199,8 @@ public override int GetHashCode() {
int hash = 1;
if (commitTimestamp_ != null) hash ^= CommitTimestamp.GetHashCode();
if (commitStats_ != null) hash ^= CommitStats.GetHashCode();
if (multiplexedSessionRetryCase_ == MultiplexedSessionRetryOneofCase.PrecommitToken) hash ^= PrecommitToken.GetHashCode();
hash ^= (int) multiplexedSessionRetryCase_;
if (_unknownFields != null) {
hash ^= _unknownFields.GetHashCode();
}
Expand All @@ -178,6 +227,10 @@ public void WriteTo(pb::CodedOutputStream output) {
output.WriteRawTag(18);
output.WriteMessage(CommitStats);
}
if (multiplexedSessionRetryCase_ == MultiplexedSessionRetryOneofCase.PrecommitToken) {
output.WriteRawTag(34);
output.WriteMessage(PrecommitToken);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(output);
}
Expand All @@ -196,6 +249,10 @@ public void WriteTo(pb::CodedOutputStream output) {
output.WriteRawTag(18);
output.WriteMessage(CommitStats);
}
if (multiplexedSessionRetryCase_ == MultiplexedSessionRetryOneofCase.PrecommitToken) {
output.WriteRawTag(34);
output.WriteMessage(PrecommitToken);
}
if (_unknownFields != null) {
_unknownFields.WriteTo(ref output);
}
Expand All @@ -212,6 +269,9 @@ public int CalculateSize() {
if (commitStats_ != null) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(CommitStats);
}
if (multiplexedSessionRetryCase_ == MultiplexedSessionRetryOneofCase.PrecommitToken) {
size += 1 + pb::CodedOutputStream.ComputeMessageSize(PrecommitToken);
}
if (_unknownFields != null) {
size += _unknownFields.CalculateSize();
}
Expand All @@ -236,6 +296,15 @@ public void MergeFrom(CommitResponse other) {
}
CommitStats.MergeFrom(other.CommitStats);
}
switch (other.MultiplexedSessionRetryCase) {
case MultiplexedSessionRetryOneofCase.PrecommitToken:
if (PrecommitToken == null) {
PrecommitToken = new global::Google.Cloud.Spanner.V1.MultiplexedSessionPrecommitToken();
}
PrecommitToken.MergeFrom(other.PrecommitToken);
break;
}

_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
}

Expand Down Expand Up @@ -265,6 +334,15 @@ public void MergeFrom(pb::CodedInputStream input) {
input.ReadMessage(CommitStats);
break;
}
case 34: {
global::Google.Cloud.Spanner.V1.MultiplexedSessionPrecommitToken subBuilder = new global::Google.Cloud.Spanner.V1.MultiplexedSessionPrecommitToken();
if (multiplexedSessionRetryCase_ == MultiplexedSessionRetryOneofCase.PrecommitToken) {
subBuilder.MergeFrom(PrecommitToken);
}
input.ReadMessage(subBuilder);
PrecommitToken = subBuilder;
break;
}
}
}
#endif
Expand Down Expand Up @@ -294,6 +372,15 @@ public void MergeFrom(pb::CodedInputStream input) {
input.ReadMessage(CommitStats);
break;
}
case 34: {
global::Google.Cloud.Spanner.V1.MultiplexedSessionPrecommitToken subBuilder = new global::Google.Cloud.Spanner.V1.MultiplexedSessionPrecommitToken();
if (multiplexedSessionRetryCase_ == MultiplexedSessionRetryOneofCase.PrecommitToken) {
subBuilder.MergeFrom(PrecommitToken);
}
input.ReadMessage(subBuilder);
PrecommitToken = subBuilder;
break;
}
}
}
}
Expand Down
Loading

0 comments on commit 2c001a6

Please sign in to comment.