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

Unified Diff: service/datastore/checkfilter.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/datastore/checkfilter.go
diff --git a/service/datastore/checkfilter.go b/service/datastore/checkfilter.go
index 478fd925b1bfbed630b1b207d7747b5637fd59de..3dd49f1b359327823c48a76e31fec69b5ee2f78e 100644
--- a/service/datastore/checkfilter.go
+++ b/service/datastore/checkfilter.go
@@ -7,19 +7,19 @@ package datastore
import (
"fmt"
- "github.com/luci/gae/service/info"
"github.com/luci/luci-go/common/errors"
+
"golang.org/x/net/context"
)
type checkFilter struct {
RawInterface
- aid string
- ns string
+ kc KeyContext
}
func (tcf *checkFilter) RunInTransaction(f func(c context.Context) error, opts *TransactionOptions) error {
+
if f == nil {
return fmt.Errorf("datastore: RunInTransaction function is nil")
}
@@ -45,7 +45,7 @@ func (tcf *checkFilter) GetMulti(keys []*Key, meta MultiMetaGetter, cb GetMultiC
}
lme := errors.NewLazyMultiError(len(keys))
for i, k := range keys {
- if k.IsIncomplete() || !k.Valid(true, tcf.aid, tcf.ns) {
+ if k.IsIncomplete() || !k.Valid(true, tcf.kc) {
lme.Assign(i, ErrInvalidKey)
}
}
@@ -70,7 +70,7 @@ func (tcf *checkFilter) PutMulti(keys []*Key, vals []PropertyMap, cb NewKeyCB) e
}
lme := errors.NewLazyMultiError(len(keys))
for i, k := range keys {
- if !k.PartialValid(tcf.aid, tcf.ns) {
+ if !k.PartialValid(tcf.kc) {
lme.Assign(i, ErrInvalidKey)
continue
}
@@ -98,7 +98,7 @@ func (tcf *checkFilter) DeleteMulti(keys []*Key, cb DeleteMultiCB) error {
}
lme := errors.NewLazyMultiError(len(keys))
for i, k := range keys {
- if k.IsIncomplete() || !k.Valid(false, tcf.aid, tcf.ns) {
+ if k.IsIncomplete() || !k.Valid(false, tcf.kc) {
lme.Assign(i, ErrInvalidKey)
}
}
@@ -112,7 +112,23 @@ func (tcf *checkFilter) DeleteMulti(keys []*Key, cb DeleteMultiCB) error {
}
func applyCheckFilter(c context.Context, i RawInterface) RawInterface {
- inf := info.Get(c)
- ns, _ := inf.GetNamespace()
- return &checkFilter{i, inf.FullyQualifiedAppID(), ns}
+ return &checkFilter{
+ RawInterface: i,
+ kc: GetKeyContext(c),
+ }
+}
+
+func (tcf *checkFilter) WithTransaction(t Transaction) context.Context {
+ // TODO(dnj): Currently only support for entering nil Transactions (i.e.,
+ // clearing the current Transaction and working against the raw
+ // non-transactional datastore instance) is supported. This will change when
+ // support for arbitrary transactions is added to the `impl/prod` datastore.
+ // Currently, support could be added to the `impl/memory` and `impl/cloud`
+ // implementations rather easily, but since `impl/prod` is the main
+ // implementation, we will gate formally supporting fluid transactions on
+ // adding support there.
+ if t != nil {
+ panic(errors.New("support for entering non-nil Transaction is not implenented"))
+ }
+ return tcf.RawInterface.WithTransaction(t)
}

Powered by Google App Engine
This is Rietveld 408576698