From 0ed730f27474890a727a72bdc85e6d20715e2f87 Mon Sep 17 00:00:00 2001 From: Google APIs Date: Mon, 11 Apr 2022 09:33:41 -0700 Subject: [PATCH] feat: expose new read_time API fields, currently only available in private preview PiperOrigin-RevId: 440914241 --- google/datastore/v1/datastore.proto | 27 ++++++++++++++++++++++++++- google/datastore/v1/query.proto | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/google/datastore/v1/datastore.proto b/google/datastore/v1/datastore.proto index 6a29b0e984070..22d930ad0d8ff 100644 --- a/google/datastore/v1/datastore.proto +++ b/google/datastore/v1/datastore.proto @@ -21,6 +21,7 @@ import "google/api/client.proto"; import "google/api/field_behavior.proto"; import "google/datastore/v1/entity.proto"; import "google/datastore/v1/query.proto"; +import "google/protobuf/timestamp.proto"; option csharp_namespace = "Google.Cloud.Datastore.V1"; option go_package = "google.golang.org/genproto/googleapis/datastore/v1;datastore"; @@ -138,6 +139,9 @@ message LookupResponse { // order of results in this field is undefined and has no relation to the // order of the keys in the input. repeated Key deferred = 3; + + // The time at which these entities were read or found missing. + google.protobuf.Timestamp read_time = 7; } // The request for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery]. @@ -259,6 +263,9 @@ message CommitResponse { // The number of index entries updated during the commit, or zero if none were // updated. int32 index_updates = 4; + + // The transaction commit timestamp. Not set for non-transactional commits. + google.protobuf.Timestamp commit_time = 8; } // The request for [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds]. @@ -332,6 +339,11 @@ message Mutation { // to. If this does not match the current version on the server, the // mutation conflicts. int64 base_version = 8; + + // The update time of the entity that this mutation is being applied + // to. If this does not match the current update time on the server, the + // mutation conflicts. + google.protobuf.Timestamp update_time = 11; } } @@ -348,6 +360,12 @@ message MutationResult { // than the version of any possible future entity. int64 version = 4; + // The update time of the entity on the server after processing the mutation. + // If the mutation doesn't change anything on the server, then the timestamp + // will be the update timestamp of the current entity. This field will not be + // set after a 'delete'. + google.protobuf.Timestamp update_time = 6; + // Whether a conflict was detected for this mutation. Always false when a // conflict detection strategy field is not set in the mutation. bool conflict_detected = 5; @@ -386,6 +404,11 @@ message ReadOptions { // transaction identifier is returned by a call to // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. bytes transaction = 2; + + // Reads entities as they were at the given time. This may not be older + // than 270 seconds. This value is only supported for Cloud Firestore in + // Datastore mode. + google.protobuf.Timestamp read_time = 4; } } @@ -403,7 +426,9 @@ message TransactionOptions { // Options specific to read-only transactions. message ReadOnly { - + // Reads entities at the given time. + // This may not be older than 60 seconds. + google.protobuf.Timestamp read_time = 1; } // The `mode` of the transaction, indicating whether write operations are diff --git a/google/datastore/v1/query.proto b/google/datastore/v1/query.proto index 3e64618393b2b..00c020021fba9 100644 --- a/google/datastore/v1/query.proto +++ b/google/datastore/v1/query.proto @@ -17,6 +17,7 @@ syntax = "proto3"; package google.datastore.v1; import "google/datastore/v1/entity.proto"; +import "google/protobuf/timestamp.proto"; import "google/protobuf/wrappers.proto"; option csharp_namespace = "Google.Cloud.Datastore.V1"; @@ -62,6 +63,12 @@ message EntityResult { // is always set except for eventually consistent reads. int64 version = 4; + // The time at which the entity was last changed. + // This field is set for [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity + // results. + // If this entity is missing, this field will not be set. + google.protobuf.Timestamp update_time = 5; + // A cursor that points to the position after the result entity. // Set only when the `EntityResult` is part of a `QueryResultBatch` message. bytes cursor = 3; @@ -353,4 +360,16 @@ message QueryResultBatch { // is valid for all preceding batches. // The value will be zero for eventually consistent queries. int64 snapshot_version = 7; + + // Read timestamp this batch was returned from. + // This applies to the range of results from the query's `start_cursor` (or + // the beginning of the query if no cursor was given) to this batch's + // `end_cursor` (not the query's `end_cursor`). + // + // In a single transaction, subsequent query result batches for the same query + // can have a greater timestamp. Each batch's read timestamp + // is valid for all preceding batches. + // This value will not be set for eventually consistent queries in Cloud + // Datastore. + google.protobuf.Timestamp read_time = 8; }