Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Unified Diff: filter/txnBuf/context.go

Issue 2036593002: Add GetNoTxn to txnBuf as a hack. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: fix nit Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: filter/txnBuf/context.go
diff --git a/filter/txnBuf/context.go b/filter/txnBuf/context.go
index b044328820e4a32b1c987f72c0e554b63831e732..63e1cace82b81b63833ffe9208bca19b031892d7 100644
--- a/filter/txnBuf/context.go
+++ b/filter/txnBuf/context.go
@@ -45,3 +45,17 @@ func memoryCorruption(err error) {
panic(err)
}
}
+
+// GetNoTxn allows you to to escape the buffered transaction (if any), and get
+// a non-transactional handle to the datastore. This does not invalidate the
+// currently-buffered transaction, but it also does not see any effects of it.
+//
+// TODO(iannucci): This is messy, but mostly because the way that transactions
+// work is messy. Fixing luci/gae#issues/23 would help though, because it means
+// we could make transactionality recorded by a single index in the context
+// instead of relying on function nesting.
+func GetNoTxn(c context.Context) ds.Interface {
+ c = context.WithValue(c, dsTxnBufParent, nil)
+ c = context.WithValue(c, dsTxnBufHaveLock, nil)
+ return ds.GetNoTxn(c)
+}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698