Index: service/datastore/transaction.go |
diff --git a/service/datastore/transaction.go b/service/datastore/transaction.go |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d20df57567a1e45c940f4c20a17ba5f6ff33d84d |
--- /dev/null |
+++ b/service/datastore/transaction.go |
@@ -0,0 +1,26 @@ |
+// Copyright 2015 The LUCI Authors. All rights reserved. |
+// Use of this source code is governed under the Apache License, Version 2.0 |
+// that can be found in the LICENSE file. |
+ |
+package datastore |
+ |
+import ( |
+ "golang.org/x/net/context" |
+) |
+ |
+// Transaction is a generic interface used to describe a Datastore transaction. |
+// |
+// The nil Transaction represents no transaction context. |
+type Transaction interface{} |
dnj
2016/09/01 15:25:40
ATM this is just an empty interface. At some point
iannucci
2016/09/16 01:01:13
discussed offline, but I think the only thing we'd
dnj
2016/09/16 05:44:43
Added some comment.
|
+ |
+// WithTransaction returns a Context with the supplied datastore Transaction |
+// instance installed. |
+func WithTransaction(c context.Context, t Transaction) context.Context { |
+ return Raw(c).WithTransaction(t) |
+} |
+ |
+// CurrentTransaction returns a reference to the current Transaction, or nil |
+// if the Context does not have a current Transaction. |
+func CurrentTransaction(c context.Context) Transaction { |
+ return Raw(c).CurrentTransaction() |
+} |