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

Unified Diff: service/taskqueue/context.go

Issue 2302743002: Interface update, per-method Contexts. (Closed)
Patch Set: Created 4 years, 4 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: service/taskqueue/context.go
diff --git a/service/taskqueue/context.go b/service/taskqueue/context.go
index a68ee5515da8635e22a250a7d94beeb5d1d4b70a..a08d421bbcc53e2ef2d017c616f56342279f5358 100644
--- a/service/taskqueue/context.go
+++ b/service/taskqueue/context.go
@@ -16,10 +16,8 @@ var (
)
// RawFactory is the function signature for RawFactory methods compatible with
-// SetRawFactory. wantTxn is true if the Factory should return the taskqueue in
-// the current transaction, and false if the Factory should return the
-// non-transactional (root) taskqueue service.
-type RawFactory func(c context.Context, wantTxn bool) RawInterface
+// SetRawFactory.
+type RawFactory func(c context.Context) RawInterface
// RawFilter is the function signature for a RawFilter TQ implementation. It
// gets the current TQ implementation, and returns a new TQ implementation
@@ -28,17 +26,17 @@ type RawFilter func(context.Context, RawInterface) RawInterface
// getUnfiltered gets gets the RawInterface implementation from context without
// any of the filters applied.
-func getUnfiltered(c context.Context, wantTxn bool) RawInterface {
+func getUnfiltered(c context.Context) RawInterface {
if f, ok := c.Value(taskQueueKey).(RawFactory); ok && f != nil {
- return f(c, wantTxn)
+ return f(c)
}
return nil
}
// getFiltered gets the taskqueue (transactional or not), and applies all of
// the currently installed filters to it.
-func getFiltered(c context.Context, wantTxn bool) RawInterface {
- ret := getUnfiltered(c, wantTxn)
+func getFiltered(c context.Context) RawInterface {
+ ret := getUnfiltered(c)
if ret == nil {
return nil
}
@@ -48,26 +46,9 @@ func getFiltered(c context.Context, wantTxn bool) RawInterface {
return ret
}
-// GetRaw gets the RawInterface implementation from context.
-func GetRaw(c context.Context) RawInterface {
- return getFiltered(c, true)
-}
-
-// GetRawNoTxn gets the RawInterface implementation from context. If there's a
-// currently active transaction, this will return a non-transactional connection
-// to the taskqueue, otherwise this is the same as GetRaw.
-func GetRawNoTxn(c context.Context) RawInterface {
- return getFiltered(c, false)
-}
-
-// Get gets the Interface implementation from context.
-func Get(c context.Context) Interface {
- return &taskqueueImpl{GetRaw(c)}
-}
-
-// GetNoTxn gets the Interface implementation from context.
-func GetNoTxn(c context.Context) Interface {
- return &taskqueueImpl{GetRawNoTxn(c)}
+// Raw gets the RawInterface implementation from context.
+func Raw(c context.Context) RawInterface {
+ return getFiltered(c)
}
// SetRawFactory sets the function to produce RawInterface instances, as returned by
@@ -80,7 +61,7 @@ func SetRawFactory(c context.Context, tqf RawFactory) context.Context {
// with a quick mock. This is just a shorthand SetRawFactory invocation to SetRaw
// a RawFactory which always returns the same object.
func SetRaw(c context.Context, tq RawInterface) context.Context {
- return SetRawFactory(c, func(context.Context, bool) RawInterface { return tq })
+ return SetRawFactory(c, func(context.Context) RawInterface { return tq })
}
func getCurFilters(c context.Context) []RawFilter {

Powered by Google App Engine
This is Rietveld 408576698