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

Unified Diff: go/src/infra/gae/epservice/example/service_add.go

Issue 1240573002: Reland: Refactor current GAE abstraction library to be free of the SDK* (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: expand coverage range to fit 32bit test expectations Created 5 years, 5 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
« no previous file with comments | « go/src/infra/gae/epservice/example/model.go ('k') | go/src/infra/gae/epservice/example/service_cas.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/gae/epservice/example/service_add.go
diff --git a/go/src/infra/gae/epservice/example/service_add.go b/go/src/infra/gae/epservice/example/service_add.go
index da259b0d2b9840842aa40ca99c6b16322ac9a936..46064977add4f2c5bfea553187db16a4c48ba5ec 100644
--- a/go/src/infra/gae/epservice/example/service_add.go
+++ b/go/src/infra/gae/epservice/example/service_add.go
@@ -6,9 +6,8 @@ package example
import (
"golang.org/x/net/context"
- "infra/gae/libs/wrapper"
- "infra/gae/libs/wrapper/gae"
- "infra/gae/libs/wrapper/gae/commonErrors"
+ "infra/gae/libs/gae"
+ "infra/gae/libs/gae/prod"
"github.com/GoogleCloudPlatform/go-endpoints/endpoints"
)
@@ -31,19 +30,21 @@ type AddRsp struct {
// Add adds a value to the current counter, and returns the old+new values. It
// may cause a counter to come into existance.
-func (Example) Add(c endpoints.Context, r *AddReq) (rsp *AddRsp, err error) {
+func (Example) Add(c context.Context, r *AddReq) (rsp *AddRsp, err error) {
rsp = &AddRsp{}
- ds := wrapper.GetDS(gae.Use(context.Background(), c))
- err = ds.RunInTransaction(func(context.Context) error {
- ctr := &Counter{ID: r.Name}
- if err := ds.Get(ctr); err != nil && err != commonErrors.ErrNoSuchEntityDS {
+ c = prod.Use(c)
+ err = gae.GetRDS(c).RunInTransaction(func(c context.Context) error {
+ rds := gae.GetRDS(c)
+ ctr := &Counter{}
+ key := rds.NewKey("Counter", r.Name, 0, nil)
+ if err := rds.Get(key, ctr); err != nil && err != gae.ErrDSNoSuchEntity {
return err
}
rsp.Prev = ctr.Val
ctr.Val += r.Delta
rsp.Cur = ctr.Val
- _, err := ds.Put(ctr)
+ _, err := rds.Put(key, ctr)
return err
}, nil)
return
« no previous file with comments | « go/src/infra/gae/epservice/example/model.go ('k') | go/src/infra/gae/epservice/example/service_cas.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698