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

Unified Diff: common/meter/config.go

Issue 1679023005: Add Context cancellation to clock. (Closed) Base URL: https://github.com/luci/luci-go@master
Patch Set: Actually upload the patch. 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
« no previous file with comments | « common/gcloud/pubsub/subscriber/subscriber.go ('k') | common/meter/config_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/meter/config.go
diff --git a/common/meter/config.go b/common/meter/config.go
deleted file mode 100644
index b77e454ae5a5b66db2ca28fd3d7e745fc8934958..0000000000000000000000000000000000000000
--- a/common/meter/config.go
+++ /dev/null
@@ -1,59 +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 meter
-
-import (
- "time"
-)
-
-const (
- // The size of the work ingest channel (Add, AddWait), which holds work until
- // it's dequeued by the consumeWork loop.
- defaultAddBufferSize = 16
-)
-
-// Config is the set of meter configuration parameters.
-type Config struct {
- // Count is the maximum number of work items to buffer before automatically
- // flushing.
- Count int
- // Delay is the maximum amount of time to wait after an element has been
- // buffered before automatically flushing it.
- Delay time.Duration
-
- // AddBufferSize is the size of the work ingest channel buffer. If zero, a
- // default size will be used.
- AddBufferSize int
-
- // Callback is the work callback method that is invoked with flushed Meter work.
- //
- // All callback invocations are made from the same goroutine, and thus
- // synchronous with each other. Therefore, any non-trivial work that needs to be
- // done based on the callback must be handled in a separate goroutine.
- Callback func([]interface{})
-
- // IngestCallback is a callback method that is invoked when the meter ingests
- // a new unit of work. If it returns true, a flush will be triggered. This is
- // intended to facilitate external accounting.
- //
- // All callback invocations are made from the same goroutine, and thus
- // synchronous with each other.
- IngestCallback func(interface{}) bool
-}
-
-// HasFlushConstraints tests if the current configuration applies any flushing
-// constraints. A meter without flush constraints will flush after each message.
-func (c *Config) HasFlushConstraints() bool {
- return (c.Count != 0 || c.Delay != 0)
-}
-
-// getAddBufferSize returns the configuration's AddBufferSize property, or the
-// default work buffer size if the property value is zero.
-func (c *Config) getAddBufferSize() int {
- if c.AddBufferSize == 0 {
- return defaultAddBufferSize
- }
- return c.AddBufferSize
-}
« no previous file with comments | « common/gcloud/pubsub/subscriber/subscriber.go ('k') | common/meter/config_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698