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!: add support for CommitStats #522
Closed
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5e1caf4
feat: add CommitStats
olavloite 35e2c21
fix: add missing methods to clirr-ignored-diff
olavloite f7d7ad5
fix: make test cases independent of each other
olavloite f0eab92
docs: add comments to CommitStats
olavloite 1fdf282
docs: add clearifying comment
olavloite c9e707b
feat: change response type of write instead of overload
olavloite 1a1adc9
fix: add clirr differences
olavloite File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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,54 @@ | ||
on: | ||
pull_request: | ||
name: auto-merge-readme | ||
jobs: | ||
approve: | ||
runs-on: ubuntu-latest | ||
if: github.repository_owner == 'googleapis' && github.head_ref == 'autosynth-readme' | ||
steps: | ||
- uses: actions/github-script@v3.0.0 | ||
with: | ||
github-token: ${{secrets.YOSHI_APPROVER_TOKEN}} | ||
script: | | ||
// only approve PRs from yoshi-automation | ||
if (context.payload.pull_request.user.login !== "yoshi-automation") { | ||
return; | ||
} | ||
|
||
// only approve PRs like "chore: release <release version>" | ||
if (!context.payload.pull_request.title === "chore: regenerate README") { | ||
return; | ||
} | ||
|
||
// only approve PRs with README.md and synth.metadata changes | ||
const files = new Set( | ||
( | ||
await github.paginate( | ||
github.pulls.listFiles.endpoint({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
pull_number: context.payload.pull_request.number, | ||
}) | ||
) | ||
).map(file => file.filename) | ||
); | ||
if (files.size != 2 || !files.has("README.md") || !files.has(".github/readme/synth.metadata/synth.metadata")) { | ||
return; | ||
} | ||
|
||
// approve README regeneration PR | ||
await github.pulls.createReview({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: 'Rubber stamped PR!', | ||
pull_number: context.payload.pull_request.number, | ||
event: 'APPROVE' | ||
}); | ||
|
||
// attach automerge label | ||
await github.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.payload.pull_request.number, | ||
labels: ['automerge'] | ||
}); |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
76 changes: 76 additions & 0 deletions
76
google-cloud-spanner/src/main/java/com/google/cloud/spanner/CommitStats.java
This file contains 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,76 @@ | ||
/* | ||
* Copyright 2020 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.spanner; | ||
|
||
import com.google.common.base.Preconditions; | ||
import org.threeten.bp.Duration; | ||
import org.threeten.bp.temporal.ChronoUnit; | ||
|
||
/** | ||
* Commit statistics are returned by a read/write transaction if specifically requested. | ||
* | ||
* <p>Use one of the following options to run a transaction that returns {@link CommitStats}: | ||
* | ||
* <ul> | ||
* <li>{@link TransactionRunner#withCommitStats()} | ||
* <li>{@link TransactionManager#withCommitStats()} | ||
* <li>{@link AsyncRunner#withCommitStats()} | ||
* <li>{@link AsyncTransactionManager#withCommitStats()} | ||
* <li>{@link DatabaseClient#writeWithCommitStats(Iterable)} | ||
* <li>{@link DatabaseClient#writeAtLeastOnceWithCommitStats(Iterable)} | ||
* </ul> | ||
*/ | ||
public class CommitStats { | ||
private final long mutationCount; | ||
private final Duration overloadDelay; | ||
|
||
private CommitStats(long mutationCount, Duration overloadDelay) { | ||
this.mutationCount = mutationCount; | ||
this.overloadDelay = overloadDelay; | ||
} | ||
|
||
static CommitStats fromProto(com.google.spanner.v1.CommitResponse.CommitStats proto) { | ||
Preconditions.checkNotNull(proto); | ||
return new CommitStats( | ||
proto.getMutationCount(), | ||
Duration.of(proto.getOverloadDelay().getSeconds(), ChronoUnit.SECONDS) | ||
.plusNanos(proto.getOverloadDelay().getNanos())); | ||
} | ||
|
||
/** | ||
* The number of mutations that were executed by the transaction. Insert and update operations | ||
* count with the multiplicity of the number of columns they affect. For example, inserting a new | ||
* record may count as five mutations, if values are inserted into five columns. Delete and delete | ||
* range operations count as one mutation regardless of the number of columns affected. Deleting a | ||
* row from a parent table that has the ON DELETE CASCADE annotation is also counted as one | ||
* mutation regardless of the number of interleaved child rows present. The exception to this is | ||
* if there are secondary indexes defined on rows being deleted, then the changes to the secondary | ||
* indexes will be counted individually. For example, if a table has 2 secondary indexes, deleting | ||
* a range of rows in the table will count as 1 mutation for the table, plus 2 mutations for each | ||
* row that is deleted because the rows in the secondary index might be scattered over the | ||
* key-space, making it impossible for Cloud Spanner to call a single delete range operation on | ||
* the secondary indexes. Secondary indexes include the foreign keys backing indexes. | ||
*/ | ||
public long getMutationCount() { | ||
return mutationCount; | ||
} | ||
|
||
/** The duration that the commit was delayed due to overloaded servers. */ | ||
public Duration getOverloadDelay() { | ||
return overloadDelay; | ||
} | ||
} |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this file be part of this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's part of the generated changes by running the synth tool. It should be removed before we merge it.