Skip to content

Commit

Permalink
feat: expose new read_time API fields, currently only available in pr…
Browse files Browse the repository at this point in the history
…ivate preview

PiperOrigin-RevId: 440914241
  • Loading branch information
Google APIs authored and Copybara-Service committed Apr 11, 2022
1 parent 4e55fdc commit 0ed730f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
27 changes: 26 additions & 1 deletion google/datastore/v1/datastore.proto
Expand Up @@ -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";
Expand Down Expand Up @@ -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].
Expand Down Expand Up @@ -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].
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
}

Expand All @@ -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
Expand Down
19 changes: 19 additions & 0 deletions google/datastore/v1/query.proto
Expand Up @@ -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";
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

0 comments on commit 0ed730f

Please sign in to comment.