1 // Copyright 2017 Tendermint. All rights reserved.
2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
10 // MetricTicker provides a single ticker interface for the trust metric
11 type MetricTicker interface {
12 // GetChannel returns the receive only channel that fires at each time interval
13 GetChannel() <-chan time.Time
15 // Stop will halt further activity on the ticker channel
19 // The ticker used during testing that provides manual control over time intervals
20 type TestTicker struct {
25 // NewTestTicker returns our ticker used within test routines
26 func NewTestTicker() *TestTicker {
27 c := make(chan time.Time)
33 func (t *TestTicker) GetChannel() <-chan time.Time {
37 func (t *TestTicker) Stop() {
41 // NextInterval manually sends Time on the ticker channel
42 func (t *TestTicker) NextTick() {
49 // Ticker is just a wrap around time.Ticker that allows it
50 // to meet the requirements of our interface
55 // NewTicker returns a normal time.Ticker wrapped to meet our interface
56 func NewTicker(d time.Duration) *Ticker {
57 return &Ticker{time.NewTicker(d)}
60 func (t *Ticker) GetChannel() <-chan time.Time {