From a777f1c33aabdf52d66e763bf2daddc5cba6b8c4 Mon Sep 17 00:00:00 2001 From: Ethan Bao Date: Wed, 10 Aug 2016 13:32:53 -0700 Subject: [PATCH] Update protos for datastore/v1beta3 API. --- google/datastore/v1beta3/datastore.proto | 27 ++++++++++++++++++++--- google/datastore/v1beta3/entity.proto | 2 +- google/datastore/v1beta3/query.proto | 28 +++++++++++++++++++++--- 3 files changed, 50 insertions(+), 7 deletions(-) diff --git a/google/datastore/v1beta3/datastore.proto b/google/datastore/v1beta3/datastore.proto index e36cc256..570b7b74 100644 --- a/google/datastore/v1beta3/datastore.proto +++ b/google/datastore/v1beta3/datastore.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2015, Google Inc. +// Copyright 2016 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -32,7 +32,6 @@ option java_package = "com.google.datastore.v1beta3"; // input keys sets the project ID (if not already set) to the project ID from // the request. // -// service Datastore { // Looks up entities by key. rpc Lookup(LookupRequest) returns (LookupResponse) { @@ -258,6 +257,15 @@ message Mutation { // Must have a complete key path and must not be reserved/read-only. Key delete = 7; } + + // When set, the server will detect whether or not this mutation conflicts + // with the current version of the entity on the server. Conflicting mutations + // are not applied, and are marked as such in MutationResult. + oneof conflict_detection_strategy { + // The version of the entity that this mutation is being applied to. If this + // does not match the current version on the server, the mutation conflicts. + int64 base_version = 8; + } } // The result of applying a mutation. @@ -265,6 +273,17 @@ message MutationResult { // The automatically allocated key. // Set only when the mutation allocated a key. Key key = 3; + + // The version of the entity on the server after processing the mutation. If + // the mutation doesn't change anything on the server, then the version will + // be the version of the current entity or, if no entity is present, a version + // that is strictly greater than the version of any previous entity and less + // than the version of any possible future entity. + int64 version = 4; + + // 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; } // The options shared by read requests. @@ -289,7 +308,9 @@ message ReadOptions { // Cannot be set to `STRONG` for global queries. ReadConsistency read_consistency = 1; - // The transaction in which to read. + // The identifier of the transaction in which to read. A + // transaction identifier is returned by a call to + // [BeginTransaction][google.datastore.v1beta3.Datastore.BeginTransaction]. bytes transaction = 2; } } diff --git a/google/datastore/v1beta3/entity.proto b/google/datastore/v1beta3/entity.proto index 871c2666..18f89cee 100644 --- a/google/datastore/v1beta3/entity.proto +++ b/google/datastore/v1beta3/entity.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2015, Google Inc. +// Copyright 2016 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. diff --git a/google/datastore/v1beta3/query.proto b/google/datastore/v1beta3/query.proto index af1808eb..3e606496 100644 --- a/google/datastore/v1beta3/query.proto +++ b/google/datastore/v1beta3/query.proto @@ -1,4 +1,4 @@ -// Copyright (c) 2015, Google Inc. +// Copyright 2016 Google Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -50,6 +50,16 @@ message EntityResult { // The resulting entity. Entity entity = 1; + // The version of the entity, a strictly positive number that monotonically + // increases with changes to the entity. + // + // This field is set for [`FULL`] + // [google.datastore.v1beta3.EntityResult.ResultType.FULL] entity results. + // For [missing][google.datastore.v1beta3.LookupResponse.missing] entities in + // `LookupResponse`, this is the version of the snapshot that was used to look + // up the entity, and it is always set except for eventually consistent reads. + int64 version = 4; + // 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; @@ -76,11 +86,13 @@ message Query { repeated PropertyReference distinct_on = 6; // A starting point for the query results. Query cursors are - // returned in query result batches. + // returned in query result batches and + // [can only be used to continue the same query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). bytes start_cursor = 7; // An ending point for the query results. Query cursors are - // returned in query result batches. + // returned in query result batches and + // [can only be used to limit the same query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). bytes end_cursor = 8; // The number of results to skip. Applies before limit, but after all other @@ -279,4 +291,14 @@ message QueryResultBatch { // The state of the query after the current batch. MoreResultsType more_results = 5; + + // The version number of the snapshot 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 snapshot version number. Each batch's snapshot version + // is valid for all preceding batches. + int64 snapshot_version = 7; }