google-cloud-firestore 2.12.0 → 2.13.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/AUTHENTICATION.md +8 -26
- data/CHANGELOG.md +12 -0
- data/lib/google/cloud/firestore/bulk_commit_batch.rb +73 -0
- data/lib/google/cloud/firestore/bulk_writer.rb +558 -0
- data/lib/google/cloud/firestore/bulk_writer_exception.rb +40 -0
- data/lib/google/cloud/firestore/bulk_writer_operation.rb +126 -0
- data/lib/google/cloud/firestore/bulk_writer_scheduler.rb +164 -0
- data/lib/google/cloud/firestore/client.rb +30 -0
- data/lib/google/cloud/firestore/convert.rb +1 -1
- data/lib/google/cloud/firestore/errors.rb +60 -0
- data/lib/google/cloud/firestore/promise/future.rb +97 -0
- data/lib/google/cloud/firestore/rate_limiter.rb +80 -0
- data/lib/google/cloud/firestore/service.rb +13 -1
- data/lib/google/cloud/firestore/version.rb +1 -1
- metadata +10 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30cb17b1e946e584cbe565b74143e0051f93bc4666f11a183a0f3f0a541b8a9d
|
4
|
+
data.tar.gz: 18b71ed2191e4f15e6bc667f8e6825e1c33d66dc3f98a7753536cd87a6dff177
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 539e3c8a868b4ece85550090a53829d615ba519bf4e0eaaea4e7ac5601977be51c5978fc8eb5ac12d2ea4e3e8c4b803c0a6a406111c381d45983516accafb3c0
|
7
|
+
data.tar.gz: a95df5fec2c114cbdde41bd78b6835664865d09a900b445f2b4deb595a4ba6cd761f777c9ce08746604b7289727d9f36b218033e3bde6261365f6835d4ab3df8
|
data/AUTHENTICATION.md
CHANGED
@@ -124,15 +124,6 @@ To configure your system for this, simply:
|
|
124
124
|
**NOTE:** This is _not_ recommended for running in production. The Cloud SDK
|
125
125
|
*should* only be used during development.
|
126
126
|
|
127
|
-
[gce-how-to]: https://cloud.google.com/compute/docs/authentication#using
|
128
|
-
[dev-console]: https://console.cloud.google.com/project
|
129
|
-
|
130
|
-
[enable-apis]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/enable-apis.png
|
131
|
-
|
132
|
-
[create-new-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account.png
|
133
|
-
[create-new-service-account-existing-keys]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/create-new-service-account-existing-keys.png
|
134
|
-
[reuse-service-account]: https://raw.githubusercontent.com/GoogleCloudPlatform/gcloud-common/master/authentication/reuse-service-account.png
|
135
|
-
|
136
127
|
## Creating a Service Account
|
137
128
|
|
138
129
|
Google Cloud requires a **Project ID** and **Service Account Credentials** to
|
@@ -143,31 +134,22 @@ If you are not running this client within [Google Cloud Platform
|
|
143
134
|
environments](#google-cloud-platform-environments), you need a Google
|
144
135
|
Developers service account.
|
145
136
|
|
146
|
-
1. Visit the [Google
|
137
|
+
1. Visit the [Google Cloud Console](https://console.cloud.google.com/project).
|
147
138
|
1. Create a new project or click on an existing project.
|
148
|
-
1. Activate the
|
139
|
+
1. Activate the menu in the upper left and select **APIs & Services**. From
|
149
140
|
here, you will enable the APIs that your application requires.
|
150
141
|
|
151
|
-
![Enable the APIs that your application requires][enable-apis]
|
152
|
-
|
153
142
|
*Note: You may need to enable billing in order to use these services.*
|
154
143
|
|
155
144
|
1. Select **Credentials** from the side navigation.
|
156
145
|
|
157
|
-
|
158
|
-
|
159
|
-
![Create a new service account][create-new-service-account]
|
160
|
-
|
161
|
-
![Create a new service account With Existing Keys][create-new-service-account-existing-keys]
|
162
|
-
|
163
|
-
Find the "Add credentials" drop down and select "Service account" to be
|
164
|
-
guided through downloading a new JSON key file.
|
165
|
-
|
166
|
-
If you want to re-use an existing service account, you can easily generate a
|
167
|
-
new key file. Just select the account you wish to re-use, and click "Generate
|
168
|
-
new JSON key":
|
146
|
+
Find the "Create credentials" drop down near the top of the page, and select
|
147
|
+
"Service account" to be guided through downloading a new JSON key file.
|
169
148
|
|
170
|
-
|
149
|
+
If you want to re-use an existing service account, you can easily generate
|
150
|
+
a new key file. Just select the account you wish to re-use click the pencil
|
151
|
+
tool on the right side to edit the service account, select the **Keys** tab,
|
152
|
+
and then select **Add Key**.
|
171
153
|
|
172
154
|
The key file you download will be used by this library to authenticate API
|
173
155
|
requests and should be stored in a secure location.
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
+
### 2.13.1 (2023-06-16)
|
4
|
+
|
5
|
+
#### Documentation
|
6
|
+
|
7
|
+
* Fixed broken links in authentication documentation ([#21619](https://github.com/googleapis/google-cloud-ruby/issues/21619))
|
8
|
+
|
9
|
+
### 2.13.0 (2023-05-10)
|
10
|
+
|
11
|
+
#### Features
|
12
|
+
|
13
|
+
* Added support for bulk writer ([#21426](https://github.com/googleapis/google-cloud-ruby/issues/21426))
|
14
|
+
|
3
15
|
### 2.12.0 (2023-04-20)
|
4
16
|
|
5
17
|
#### Features
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Copyright 2023 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
module Google
|
17
|
+
module Cloud
|
18
|
+
module Firestore
|
19
|
+
##
|
20
|
+
#
|
21
|
+
# @private Accumulate write operations to be sent in a batch. Use this for higher
|
22
|
+
# volumes (e.g., via `BulkWriter`) and when the order of operations
|
23
|
+
# within a given batch is unimportant.
|
24
|
+
#
|
25
|
+
# Because the order in which individual write operations are applied to the database
|
26
|
+
# is not guaranteed, `batch_write` RPCs can never contain multiple operations
|
27
|
+
# to the same document. In practice, the BulkWriter class handle this case.
|
28
|
+
#
|
29
|
+
class BulkCommitBatch
|
30
|
+
attr_reader :operations
|
31
|
+
|
32
|
+
##
|
33
|
+
# Initialize the object
|
34
|
+
def initialize service, operations
|
35
|
+
@service = service
|
36
|
+
@operations = operations
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# Updates the operation based on the result received from the API request.
|
41
|
+
#
|
42
|
+
# @param [Google::Cloud::Firestore::V1::BatchWriteResponse] responses
|
43
|
+
#
|
44
|
+
# @return [nil]
|
45
|
+
#
|
46
|
+
def parse_results responses
|
47
|
+
@operations.zip responses.write_results, responses.status do |operation, write_result, status|
|
48
|
+
begin
|
49
|
+
status&.code&.zero? ? operation.on_success(write_result) : operation.on_failure(status)
|
50
|
+
rescue StandardError
|
51
|
+
# TODO: Log the error while parsing response
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# Makes the BatchWrite API request with all the operations in the batch and
|
58
|
+
# parses the results for each operation.
|
59
|
+
#
|
60
|
+
# @return [nil]
|
61
|
+
#
|
62
|
+
def commit
|
63
|
+
begin
|
64
|
+
responses = @service.batch_write @operations.map(&:write)
|
65
|
+
parse_results responses
|
66
|
+
rescue StandardError => e
|
67
|
+
raise BulkCommitBatchError, e
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|