Skip to content

Commit

Permalink
Add GetNoTxn to txnBuf as a hack.
Browse files Browse the repository at this point in the history
I really don't like this but short of fixing #23, I don't think there's much we
can do.

R=dnj@chromium.org, nodir@chromium.org
BUG=

Review-Url: https://codereview.chromium.org/2036593002
  • Loading branch information
riannucci authored and Commit bot committed Jun 2, 2016
1 parent ba34d4d commit 5787dea
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions filter/txnBuf/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 5787dea

Please sign in to comment.