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

Unified Diff: appengine/apigen_examples/dumb_counter/dumbCounter/service_cas.go

Issue 1750143003: Remove ephelper and other endpoints code. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Created 4 years, 10 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: appengine/apigen_examples/dumb_counter/dumbCounter/service_cas.go
diff --git a/appengine/apigen_examples/dumb_counter/dumbCounter/service_cas.go b/appengine/apigen_examples/dumb_counter/dumbCounter/service_cas.go
deleted file mode 100644
index bb6077621f71238aded8395e411b8b54f2180b42..0000000000000000000000000000000000000000
--- a/appengine/apigen_examples/dumb_counter/dumbCounter/service_cas.go
+++ /dev/null
@@ -1,52 +0,0 @@
-// 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 dumbCounter
-
-import (
- "github.com/GoogleCloudPlatform/go-endpoints/endpoints"
- dstore "github.com/luci/gae/service/datastore"
- "golang.org/x/net/context"
-)
-
-// CASReq is the input for the CAS RPC
-type CASReq struct {
- Name string `endpoints:"required"`
-
- OldVal int64 `json:",string"`
- NewVal int64 `json:",string"`
-}
-
-// CAS does an atomic compare-and-swap on a counter.
-func (e *Example) CAS(c context.Context, r *CASReq) (err error) {
- c, err = e.Use(c, casMethodInfo)
- if err != nil {
- return
- }
-
- success := false
- err = dstore.Get(c).RunInTransaction(func(c context.Context) error {
- ds := dstore.Get(c)
- ctr := &Counter{Name: r.Name}
- if err := ds.Get(ctr); err != nil {
- return err
- }
- if ctr.Val == r.OldVal {
- success = true
- ctr.Val = r.NewVal
- return ds.Put(ctr)
- }
- success = false
- return nil
- }, nil)
- if err == nil && !success {
- err = endpoints.ConflictError
- }
- return
-}
-
-var casMethodInfo = &endpoints.MethodInfo{
- Path: "counter/{Name}/cas",
- Desc: "Compare and swap a counter value",
-}

Powered by Google App Engine
This is Rietveld 408576698