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

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

Issue 1153473008: A client/server helper wrapper for endpoints in Go. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: rm newline Created 5 years, 6 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: go/src/infra/gae/epservice/example/service_currentvalue.go
diff --git a/go/src/infra/gae/epservice/example/service_currentvalue.go b/go/src/infra/gae/epservice/example/service_currentvalue.go
new file mode 100644
index 0000000000000000000000000000000000000000..ec64fcae55712f0ef80c3f21d0158d93593265e1
--- /dev/null
+++ b/go/src/infra/gae/epservice/example/service_currentvalue.go
@@ -0,0 +1,43 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package example
+
+import (
+ "golang.org/x/net/context"
+ "infra/gae/libs/wrapper"
+ "infra/gae/libs/wrapper/gae"
+
+ "github.com/GoogleCloudPlatform/go-endpoints/endpoints"
+)
+
+// CurrentValueReq describes the inputs to the CurrentValueReq RPC.
+type CurrentValueReq struct {
+ Name string `endpoints:"required"`
+}
+
+// CurrentValueRsp describes the outputs of the CurrentValueReq RPC.
+type CurrentValueRsp struct {
+ Val int64 `json:",string"`
+}
+
+// CurrentValue gets the current value of a counter (duh)
+func (Example) CurrentValue(c endpoints.Context, r *CurrentValueReq) (rsp *CurrentValueRsp, err error) {
+ ds := wrapper.GetDS(gae.Use(context.Background(), c))
+
+ ctr := &Counter{ID: r.Name}
+ if err = ds.Get(ctr); err != nil {
+ return
+ }
+
+ rsp = &CurrentValueRsp{ctr.Val}
+ return
+}
+
+func init() {
+ mi["CurrentValue"] = &endpoints.MethodInfo{
+ Path: "counter/{Name}",
+ Desc: "Returns the current value held by the named counter",
+ }
+}
« 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