Пример #1
0
// useTQ adds a gae.TaskQueue implementation to context, accessible
// by gae.GetTQ(c)
func useTQ(c context.Context) context.Context {
	return tq.SetRawFactory(c, func(ci context.Context, wantTxn bool) tq.RawInterface {
		if wantTxn {
			return tqImpl{AEContext(ci)}
		}
		return tqImpl{AEContextNoTxn(ci)}
	})
}
Пример #2
0
func useTQ(c context.Context) context.Context {
	return tq.SetRawFactory(c, func(ic context.Context, wantTxn bool) tq.RawInterface {
		ns := curGID(ic).namespace
		var tqd memContextObj

		if !wantTxn {
			tqd = curNoTxn(ic).Get(memContextTQIdx)
		} else {
			tqd = cur(ic).Get(memContextTQIdx)
		}

		if x, ok := tqd.(*taskQueueData); ok {
			return &taskqueueImpl{x, ic, ns}
		}
		return &taskqueueTxnImpl{tqd.(*txnTaskQueueData), ic, ns}
	})
}