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

Side by Side Diff: go/src/infra/gae/epservice/example/service_currentvalue.go

Issue 1227183003: Change RawDatastore to do less reflection. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@move_dummy
Patch Set: fix No/ShouldIndex 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package example 5 package example
6 6
7 import ( 7 import (
8 "golang.org/x/net/context" 8 "golang.org/x/net/context"
9
9 "infra/gae/libs/gae" 10 "infra/gae/libs/gae"
11 "infra/gae/libs/gae/helper"
10 "infra/gae/libs/gae/prod" 12 "infra/gae/libs/gae/prod"
11 13
12 "github.com/GoogleCloudPlatform/go-endpoints/endpoints" 14 "github.com/GoogleCloudPlatform/go-endpoints/endpoints"
13 ) 15 )
14 16
15 // CurrentValueReq describes the inputs to the CurrentValueReq RPC. 17 // CurrentValueReq describes the inputs to the CurrentValueReq RPC.
16 type CurrentValueReq struct { 18 type CurrentValueReq struct {
17 Name string `endpoints:"required"` 19 Name string `endpoints:"required"`
18 } 20 }
19 21
20 // CurrentValueRsp describes the outputs of the CurrentValueReq RPC. 22 // CurrentValueRsp describes the outputs of the CurrentValueReq RPC.
21 type CurrentValueRsp struct { 23 type CurrentValueRsp struct {
22 Val int64 `json:",string"` 24 Val int64 `json:",string"`
23 } 25 }
24 26
25 // CurrentValue gets the current value of a counter (duh) 27 // CurrentValue gets the current value of a counter (duh)
26 func (Example) CurrentValue(c context.Context, r *CurrentValueReq) (rsp *Current ValueRsp, err error) { 28 func (Example) CurrentValue(c context.Context, r *CurrentValueReq) (rsp *Current ValueRsp, err error) {
27 c = prod.Use(c) 29 c = prod.Use(c)
28 rds := gae.GetRDS(c) 30 rds := gae.GetRDS(c)
29 31
30 key := rds.NewKey("Counter", r.Name, 0, nil) 32 key := rds.NewKey("Counter", r.Name, 0, nil)
31 ctr := &Counter{} 33 ctr := &Counter{}
32 » if err = rds.Get(key, ctr); err != nil { 34 » if err = rds.Get(key, helper.GetPLS(ctr)); err != nil {
33 return 35 return
34 } 36 }
35 37
36 rsp = &CurrentValueRsp{ctr.Val} 38 rsp = &CurrentValueRsp{ctr.Val}
37 return 39 return
38 } 40 }
39 41
40 func init() { 42 func init() {
41 mi["CurrentValue"] = &endpoints.MethodInfo{ 43 mi["CurrentValue"] = &endpoints.MethodInfo{
42 Path: "counter/{Name}", 44 Path: "counter/{Name}",
43 Desc: "Returns the current value held by the named counter", 45 Desc: "Returns the current value held by the named counter",
44 } 46 }
45 } 47 }
OLDNEW
« no previous file with comments | « go/src/infra/gae/epservice/example/service_cas.go ('k') | go/src/infra/gae/epservice/example/service_list.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698