OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. |
| 4 |
| 5 package datastore |
| 6 |
| 7 import ( |
| 8 "golang.org/x/net/context" |
| 9 ) |
| 10 |
| 11 // Transaction is a generic interface used to describe a Datastore transaction. |
| 12 // |
| 13 // The nil Transaction represents no transaction context. |
| 14 // |
| 15 // TODO: Add some functionality here. Ideas include: |
| 16 // - Active() bool: is the transaction currently active? |
| 17 // - AffectedGroups() []*ds.Key: list the groups that have been referenced
in |
| 18 // this Transaction so far. |
| 19 type Transaction interface{} |
| 20 |
| 21 // WithoutTransaction returns a Context that isn't bound to a transaction. |
| 22 // |
| 23 // This can be useful to perform non-transactional tasks given only a Context |
| 24 // that is bound to a transaction. |
| 25 func WithoutTransaction(c context.Context) context.Context { |
| 26 return Raw(c).WithoutTransaction() |
| 27 } |
| 28 |
| 29 // CurrentTransaction returns a reference to the current Transaction, or nil |
| 30 // if the Context does not have a current Transaction. |
| 31 func CurrentTransaction(c context.Context) Transaction { |
| 32 return Raw(c).CurrentTransaction() |
| 33 } |
OLD | NEW |