| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package dumbCounter | |
| 6 | |
| 7 import ( | |
| 8 "github.com/GoogleCloudPlatform/go-endpoints/endpoints" | |
| 9 dstore "github.com/luci/gae/service/datastore" | |
| 10 "golang.org/x/net/context" | |
| 11 ) | |
| 12 | |
| 13 // ListRsp is the response from the 'List' RPC. It contains a list of Counters | |
| 14 // including their IDs and Values. | |
| 15 type ListRsp struct { | |
| 16 Counters []Counter | |
| 17 } | |
| 18 | |
| 19 // List returns a list of all the counters. Note that it's very poorly | |
| 20 // implemented! It's completely unpaged. I don't care :). | |
| 21 func (e *Example) List(c context.Context) (rsp *ListRsp, err error) { | |
| 22 c, err = e.Use(c, listMethodInfo) | |
| 23 if err != nil { | |
| 24 return | |
| 25 } | |
| 26 | |
| 27 ds := dstore.Get(c) | |
| 28 rsp = &ListRsp{} | |
| 29 err = ds.GetAll(dstore.NewQuery("Counter"), &rsp.Counters) | |
| 30 return | |
| 31 } | |
| 32 | |
| 33 var listMethodInfo = &endpoints.MethodInfo{ | |
| 34 Path: "counter", | |
| 35 Desc: "Returns all of the available counters", | |
| 36 } | |
| OLD | NEW |