Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import com.google.api.core.InternalExtensionOnly;
import com.google.cloud.Service;
import com.google.cloud.datastore.models.ExplainOptions;
import com.google.common.collect.ImmutableList;
import com.google.datastore.v1.RequestOptions;
import com.google.datastore.v1.TransactionOptions;
import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -492,6 +494,30 @@ interface TransactionCallable<T> {
@BetaApi
<T> QueryResults<T> run(Query<T> query, ExplainOptions explainOptions, ReadOption... options);

/**
* Submits a {@link Query} with specified {@link com.google.datastore.v1.RequestOptions} and
* returns its result.
*/
<T> QueryResults<T> run(Query<T> query, RequestOptions requestOptions);

/**
* Submits a {@link Query} with specified {@link com.google.datastore.v1.RequestOptions} and
* returns its result. {@link ReadOption}s can be specified if desired.
*/
<T> QueryResults<T> run(Query<T> query, RequestOptions requestOptions, ReadOption... options);

/**
* Submits a {@link Query} with specified {@link com.google.cloud.datastore.models.ExplainOptions}
* and {@link com.google.datastore.v1.RequestOptions} and returns its result. {@link ReadOption}s
* can be specified if desired.
*/
@BetaApi
<T> QueryResults<T> run(
Query<T> query,
ExplainOptions explainOptions,
RequestOptions requestOptions,
ReadOption... options);
Comment thread
rahulmane-goog marked this conversation as resolved.

/**
* Submits a {@link AggregationQuery} and returns {@link AggregationResults}. {@link ReadOption}s
* can be specified if desired.
Expand Down Expand Up @@ -537,6 +563,20 @@ interface TransactionCallable<T> {
*/
AggregationResults runAggregation(AggregationQuery query, ReadOption... options);

/**
* Submits an {@link AggregationQuery} with specified {@link
* com.google.datastore.v1.RequestOptions} and returns {@link AggregationResults}.
*/
AggregationResults runAggregation(AggregationQuery query, RequestOptions requestOptions);

/**
* Submits an {@link AggregationQuery} with specified {@link
* com.google.datastore.v1.RequestOptions} and returns {@link AggregationResults}. {@link
* ReadOption}s can be specified if desired.
*/
AggregationResults runAggregation(
AggregationQuery query, RequestOptions requestOptions, ReadOption... options);

/**
* Submits a {@link AggregationQuery} with specified {@link
* com.google.cloud.datastore.models.ExplainOptions} and returns {@link AggregationResults}.
Expand Down Expand Up @@ -564,6 +604,28 @@ interface TransactionCallable<T> {
AggregationResults runAggregation(
AggregationQuery query, ExplainOptions explainOptions, ReadOption... options);

/**
* Submits an {@link AggregationQuery} with specified {@link
* com.google.cloud.datastore.models.ExplainOptions} and {@link
* com.google.datastore.v1.RequestOptions} and returns {@link AggregationResults}.
*/
@BetaApi
AggregationResults runAggregation(
AggregationQuery query, ExplainOptions explainOptions, RequestOptions requestOptions);

/**
* Submits an {@link AggregationQuery} with specified {@link
* com.google.cloud.datastore.models.ExplainOptions} and {@link
* com.google.datastore.v1.RequestOptions} and returns {@link AggregationResults}. {@link
* ReadOption}s can be specified if desired.
*/
@BetaApi
AggregationResults runAggregation(
AggregationQuery query,
ExplainOptions explainOptions,
RequestOptions requestOptions,
ReadOption... options);

/**
* 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 Datastore client
Expand All @@ -574,4 +636,25 @@ AggregationResults runAggregation(

/** Returns true if this background resource has been shut down. */
boolean isClosed();

/**
* Returns a new Datastore client with the specified request tags added.
*
* @param requestTags the request tags to append to existing ones
*/
default Datastore withRequestTags(String... requestTags) {
return withRequestTags(java.util.Arrays.asList(requestTags));
}
Comment thread
jinseopkim0 marked this conversation as resolved.
Comment thread
rahulmane-goog marked this conversation as resolved.

/**
* Returns a new Datastore client with the specified request tags added.
*
* @param requestTags the request tags to append to existing ones
*/
default Datastore withRequestTags(List<String> requestTags) {
ImmutableList.Builder<String> builder = ImmutableList.builder();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can the requestTags be null here? And if so, would it make sense to just return the current client rather than build a new one?

e.g.

if (requestTags == null || requestTags.isEmpty()) {
    return this; 
  }

builder.addAll(getOptions().getRequestTags());
builder.addAll(requestTags);
return getOptions().toBuilder().setTags(builder.build()).build().getService();
}
}
Loading
Loading