-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat(datastore): add support for request tags #13732
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
Open
rahulmane-goog
wants to merge
8
commits into
googleapis:main
Choose a base branch
from
rahulmane-goog:feat-datastore-request-tags
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f1311d9
feat(datastore): add support for request tags
rahulmane-goog 5f377f8
fix: address code review comments regarding instance-level tags and d…
rahulmane-goog e5396c0
Fixed review comments
rahulmane-goog 88cc471
refactor(datastore): extract DatastoreExecutionOptions for query exec…
rahulmane-goog f01580b
Merge branch 'main' into feat-datastore-request-tags
rahulmane-goog d3fd1cc
refactor(datastore): update datastore execution options method signat…
rahulmane-goog c2d9004
refactor(datastore): remove redundant null check for executionOptions…
rahulmane-goog d3a5393
Merge branch 'main' into feat-datastore-request-tags
rahulmane-goog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
122 changes: 122 additions & 0 deletions
122
...e-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreExecutionOptions.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| /* | ||
| * Copyright 2026 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package com.google.cloud.datastore; | ||
|
|
||
| import com.google.api.core.BetaApi; | ||
| import com.google.cloud.datastore.models.ExplainOptions; | ||
| import com.google.common.base.Objects; | ||
| import com.google.common.base.Preconditions; | ||
| import com.google.common.collect.ImmutableList; | ||
| import com.google.datastore.v1.RequestOptions; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
| import org.jspecify.annotations.NullMarked; | ||
| import org.jspecify.annotations.Nullable; | ||
|
|
||
| /** | ||
| * Class representing options for query execution in Google Cloud Datastore. Combines {@link | ||
| * ExplainOptions}, {@link RequestOptions}, and {@link ReadOption}s. | ||
| */ | ||
| @BetaApi | ||
| @NullMarked | ||
| public class DatastoreExecutionOptions { | ||
|
|
||
| private final @Nullable ExplainOptions explainOptions; | ||
| private final @Nullable RequestOptions requestOptions; | ||
| private final List<ReadOption> readOptions; | ||
|
|
||
| private DatastoreExecutionOptions(Builder builder) { | ||
| this.explainOptions = builder.explainOptions; | ||
| this.requestOptions = builder.requestOptions; | ||
| this.readOptions = ImmutableList.copyOf(builder.readOptions); | ||
| } | ||
|
|
||
| public @Nullable ExplainOptions getExplainOptions() { | ||
| return explainOptions; | ||
| } | ||
|
|
||
| public @Nullable RequestOptions getRequestOptions() { | ||
| return requestOptions; | ||
| } | ||
|
|
||
| public List<ReadOption> getReadOptions() { | ||
| return readOptions; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { | ||
| if (this == o) return true; | ||
| if (!(o instanceof DatastoreExecutionOptions)) return false; | ||
| DatastoreExecutionOptions that = (DatastoreExecutionOptions) o; | ||
| return Objects.equal(explainOptions, that.explainOptions) | ||
| && Objects.equal(requestOptions, that.requestOptions) | ||
| && Objects.equal(readOptions, that.readOptions); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hashCode(explainOptions, requestOptions, readOptions); | ||
| } | ||
|
|
||
| public Builder toBuilder() { | ||
| return new Builder(this); | ||
| } | ||
|
|
||
| public static Builder newBuilder() { | ||
| return new Builder(); | ||
| } | ||
|
|
||
| /** Returns a default {@code DatastoreExecutionOptions} instance. */ | ||
| public static DatastoreExecutionOptions getDefaultInstance() { | ||
| return newBuilder().build(); | ||
| } | ||
|
|
||
| /** Builder for {@link DatastoreExecutionOptions}. */ | ||
| public static class Builder { | ||
| private @Nullable ExplainOptions explainOptions; | ||
| private @Nullable RequestOptions requestOptions; | ||
| private List<ReadOption> readOptions = Collections.emptyList(); | ||
|
|
||
| private Builder() {} | ||
|
|
||
| private Builder(DatastoreExecutionOptions options) { | ||
| this.explainOptions = options.explainOptions; | ||
| this.requestOptions = options.requestOptions; | ||
| this.readOptions = options.readOptions; | ||
| } | ||
|
|
||
| public Builder setExplainOptions(@Nullable ExplainOptions explainOptions) { | ||
| this.explainOptions = explainOptions; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setRequestOptions(@Nullable RequestOptions requestOptions) { | ||
| this.requestOptions = requestOptions; | ||
| return this; | ||
| } | ||
|
|
||
| public Builder setReadOptions(List<ReadOption> readOptions) { | ||
| Preconditions.checkNotNull(readOptions, "readOptions cannot be null"); | ||
| this.readOptions = readOptions; | ||
| return this; | ||
| } | ||
|
|
||
| public DatastoreExecutionOptions build() { | ||
| return new DatastoreExecutionOptions(this); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.