db: add AtomicContext#4724
Merged
algorandskiy merged 4 commits intoalgorand:masterfrom Nov 2, 2022
Merged
Conversation
02fd8b1 to
1bd0e2a
Compare
Codecov Report
@@ Coverage Diff @@
## master #4724 +/- ##
==========================================
- Coverage 54.61% 53.96% -0.65%
==========================================
Files 414 414
Lines 53516 53515 -1
==========================================
- Hits 29228 28881 -347
- Misses 21864 22199 +335
- Partials 2424 2435 +11
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
1bd0e2a to
ddcf616
Compare
brianolson
reviewed
Nov 2, 2022
Contributor
brianolson
left a comment
There was a problem hiding this comment.
good simple change except I don't like the dbCtx -> ctx rename
| start := time.Now() | ||
| ledgerGeneratecatchpointCount.Inc(nil) | ||
| err := ct.dbs.Rdb.Atomic(func(dbCtx context.Context, tx *sql.Tx) (err error) { | ||
| err := ct.dbs.Rdb.AtomicContext(ctx, func(ctx context.Context, tx *sql.Tx) (err error) { |
Contributor
There was a problem hiding this comment.
this is less clear because it shadows the outer function's param ctx
Contributor
Author
There was a problem hiding this comment.
Makes sense, fixed!
brianolson
approved these changes
Nov 2, 2022
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Atomic() doesn't accept a context, but always passes context.Background() to the callback fn.
This PR adds AtomicContext() that does accept a context and passes it to its callback.
Replaces #4104