github.com/haraldrudell/parl@v0.4.176/counter/rate.go (about)

     1  /*
     2  © 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package counter
     7  
     8  import (
     9  	"time"
    10  
    11  	"github.com/haraldrudell/parl"
    12  )
    13  
    14  type Rate struct {
    15  	RateType // String()
    16  	delta    uint64
    17  	duration time.Duration
    18  	hasValue bool
    19  }
    20  
    21  var _ parl.Rate = &Rate{}
    22  
    23  func (rt *Rate) Clone() (rate parl.Rate) {
    24  	var r2 Rate = *rt
    25  	return &r2
    26  }
    27  func (rt *Rate) Delta() (delta uint64)              { return rt.delta }
    28  func (rt *Rate) Duration() (duration time.Duration) { return rt.duration }
    29  func (rt *Rate) HasValue() (hasValue bool)          { return rt.hasValue }