// New creates a Publish for consuming and publishing metrics.
New creates a Publish for consuming and publishing metrics.
// New creates a Publish for consuming and publishing metrics .
func New(log *log.Logger, collector Collector, interval time.Duration, publisher ...Publisher) (*Publish, error) {
	p := Publish{
		log:       log,
		collector: collector,
		publisher: publisher,
		timer:     time.NewTimer(interval),
		shutdown:  make(chan struct{}),
	}
	p.wg.Add(1)
	go func() {
		defer p.wg.Done()
		for {
			p.timer.Reset(interval)
			select {
			case <-p.timer.C:
				p.update()
			case <-p.shutdown:
				return
			}
		}
	}()
	return &p, nil
}
func New ( log * log . Logger , collector Collector , interval time . Duration , publisher ... Publisher ) ( * Publish , error ) { p := Publish { log : log , collector : collector , publisher : publisher , timer : time . NewTimer ( interval ) , shutdown : make ( chan struct { } ) , } p . wg . Add ( 1 ) go func ( ) { defer p . wg . Done ( ) for { p . timer . Reset ( interval ) select { case <- p . timer . C : p . update ( ) case <- p . shutdown : return } } } ( ) return & p , nil }
New creates a Publish for consuming and publishing metrics.
New creates a Publish for consuming and publishing metrics .