Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Release bundles #466

Merged
merged 7 commits into from Dec 2, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions google-cloud-firestore/clirr-ignored-differences.xml
Expand Up @@ -18,6 +18,18 @@
<!-- see http://www.mojohaus.org/clirr-maven-plugin/examples/ignored-differences.html -->
<differences>

<!-- v2.1.1 -->
<difference>
<differenceType>7012</differenceType>
<className>com/google/cloud/firestore/Firestore</className>
<method>com.google.cloud.firestore.FirestoreBundle$Builder bundleBuilder()</method>
</difference>
<difference>
<differenceType>7012</differenceType>
<className>com/google/cloud/firestore/Firestore</className>
<method>com.google.cloud.firestore.FirestoreBundle$Builder bundleBuilder(java.lang.String)</method>
</difference>

<!-- v2.0.0 -->
<difference>
<differenceType>7002</differenceType>
Expand Down
Expand Up @@ -168,6 +168,24 @@ void getAll(
@Nonnull
WriteBatch batch();

/**
* Returns a FirestoreBundle.Builder {@link FirestoreBundle.Builder} instance using an
* automatically generated ID. The ID is used by the client SDKs loading bundles to identify if a
* bundle has been loaded before.
*/
@Nonnull
FirestoreBundle.Builder bundleBuilder();

/**
* Returns a FirestoreBundle.Builder {@link FirestoreBundle.Builder} instance for the given bundle
* ID.
*
* @param bundleId The ID is used by the client SDKs loading bundles to identify if a bundle has
* been loaded before. If null, an random string will be used for the ID.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/an/a

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

*/
@Nonnull
FirestoreBundle.Builder bundleBuilder(@Nullable String bundleId);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/@Nullable/@NotNull


/**
* Closes the gRPC channels associated with this instance and frees up their resources. This
* method blocks until all channels are closed. Once this method is called, this Firestore client
Expand Down
Expand Up @@ -54,10 +54,17 @@ public static final class Builder {
// The latest read time among all bundled documents and queries.
private Timestamp latestReadTime = Timestamp.MIN_VALUE;

public Builder(String id) {
Builder(String id) {
this.id = id;
}

/**
* Returns the ID for this bundle.
*/
wu-hui marked this conversation as resolved.
Show resolved Hide resolved
public String getId() {
return this.id;
}

/**
* Adds a Firestore document snapshot to the bundle. Both the documents data and the document

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove plural "Both the document data and...."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

* read time will be included in the bundle.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 124-129 below, for add() doc, remove plural so "Adds a Firestore query snapshot to..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Expand Down
Expand Up @@ -321,6 +321,19 @@ public <T> ApiFuture<T> runAsyncTransaction(
return transactionRunner.run();
}

@Nonnull
@Override
public FirestoreBundle.Builder bundleBuilder() {
return bundleBuilder(null);
}

@Nonnull
@Override
public FirestoreBundle.Builder bundleBuilder(@Nullable String bundleId) {
String id = bundleId == null ? autoId() : bundleId;
return new FirestoreBundle.Builder(id);
}

/** Returns the name of the Firestore project associated with this client. */
@Override
public String getDatabaseName() {
Expand Down
Expand Up @@ -1566,7 +1566,7 @@ public ApiFuture<List<T>> consume() {

@Test
public void testBuildingBundleWhenDocumentDoesNotExist() throws Exception {
FirestoreBundle.Builder bundleBuilder = new FirestoreBundle.Builder("test-bundle");
FirestoreBundle.Builder bundleBuilder = firestore.bundleBuilder("test-bundle");
DocumentSnapshot snapshot = randomDoc.get().get();
bundleBuilder.add(snapshot);

Expand Down Expand Up @@ -1595,7 +1595,7 @@ public void testBuildingBundleWithLimitQuery() throws Exception {

Query limitQuery = randomColl.orderBy("counter", Direction.DESCENDING).limit(1);
QuerySnapshot limitQuerySnap = limitQuery.get().get();
FirestoreBundle.Builder bundleBuilder = new FirestoreBundle.Builder("test-bundle");
FirestoreBundle.Builder bundleBuilder = firestore.bundleBuilder("test-bundle");
bundleBuilder.add("limit", limitQuerySnap);

// Expected bundle elements are [bundleMetadata, limitQuery,
Expand Down Expand Up @@ -1630,7 +1630,7 @@ public void testBuildingBundleWithLimitToLastQuery() throws Exception {

Query limitToLastQuery = randomColl.orderBy("counter").limitToLast(1);
QuerySnapshot limitToLastQuerySnap = limitToLastQuery.get().get();
FirestoreBundle.Builder bundleBuilder = new FirestoreBundle.Builder("test-bundle");
FirestoreBundle.Builder bundleBuilder = firestore.bundleBuilder("test-bundle");
bundleBuilder.add("limitToLast", limitToLastQuerySnap);

// Expected bundle elements are [bundleMetadata, limitToLastQuery,
Expand Down