Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 count contains 'counter' filters for all the gae services. This | 5 // Package count contains 'counter' filters for all the gae services. This |
| 6 // serves as a set of simple example filters, and also enables other filters | 6 // serves as a set of simple example filters, and also enables other filters |
| 7 // to test to see if certain underlying APIs are called when they should be | 7 // to test to see if certain underlying APIs are called when they should be |
| 8 // (e.g. for the datastore mcache filter, for example). | 8 // (e.g. for the datastore mcache filter, for example). |
| 9 package count | 9 package count |
| 10 | 10 |
| 11 import ( | 11 import ( |
| 12 "fmt" | 12 "fmt" |
| 13 "sync/atomic" | 13 "sync/atomic" |
| 14 | |
| 15 "github.com/luci/luci-go/common/errors" | |
| 14 ) | 16 ) |
| 15 | 17 |
| 16 type counter struct { | 18 type counter struct { |
| 17 value int32 | 19 value int32 |
| 18 } | 20 } |
| 19 | 21 |
| 20 func (c *counter) increment() { | 22 func (c *counter) increment() { |
| 21 atomic.AddInt32(&c.value, 1) | 23 atomic.AddInt32(&c.value, 1) |
| 22 } | 24 } |
| 23 | 25 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 55 if len(errs) > 0 { | 57 if len(errs) > 0 { |
| 56 err = errs[0] | 58 err = errs[0] |
| 57 } | 59 } |
| 58 if err == nil { | 60 if err == nil { |
| 59 e.successes.increment() | 61 e.successes.increment() |
| 60 } else { | 62 } else { |
| 61 e.errors.increment() | 63 e.errors.increment() |
| 62 } | 64 } |
| 63 return err | 65 return err |
| 64 } | 66 } |
| 67 | |
| 68 // upFilter calls "up", converting the filtered errors into nil. The filtering | |
| 69 // does not impact the original error, which is returned directly. | |
| 70 func (e *Entry) upFilter(err, filter error, filterMore ...error) error { | |
|
iannucci
2016/04/01 02:45:42
can't this just be upFilterStop? Does it ever filt
dnj
2016/04/01 21:41:05
Done.
| |
| 71 e.up(errors.Filter(err, filter, filterMore...)) | |
| 72 return err | |
| 73 } | |
| OLD | NEW |