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

Unified Diff: filter/txnBuf/ds.go

Issue 1309803004: Add transaction buffer filter. (Closed) Base URL: https://github.com/luci/gae.git@add_query_support
Patch Set: fix comments Created 5 years, 3 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
Index: filter/txnBuf/ds.go
diff --git a/filter/txnBuf/ds.go b/filter/txnBuf/ds.go
new file mode 100644
index 0000000000000000000000000000000000000000..5c13ff68d25847248856b9d26e61c4a419c568cf
--- /dev/null
+++ b/filter/txnBuf/ds.go
@@ -0,0 +1,32 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package txnBuf
+
+import (
+ "golang.org/x/net/context"
+
+ ds "github.com/luci/gae/service/datastore"
+)
+
+// 10MB is the current initial limit
+const transactionSizeLimit = 10 * 1000 * 1000
+
+type dsBuf struct {
+ ds.RawInterface
+
+ ns string
+}
+
+var _ ds.RawInterface = (*dsBuf)(nil)
+
+func (d *dsBuf) RunInTransaction(f func(context.Context) error, opts *ds.TransactionOptions) error {
iannucci 2015/09/29 03:32:22 So you can see here that in not-a-transaction, lit
+ return doRunInTransaction(d.RawInterface, f, opts)
+}
+
+func doRunInTransaction(base ds.RawInterface, f func(context.Context) error, opts *ds.TransactionOptions) error {
+ return base.RunInTransaction(func(ctx context.Context) error {
+ return withTxnBuf(ctx, f, opts)
+ }, opts)
+}

Powered by Google App Engine
This is Rietveld 408576698