Пример #1
0
// NewEmitterDial is the same as NewEmitter, but allows you to specify your own
// Dialer function. This is primarily useful for tests.
func NewEmitterDial(dialer conn.Dialer, network, address string, metricsPrefix string, flushInterval time.Duration, logger log.Logger) *Emitter {
	e := &Emitter{
		prefix: metricsPrefix,
		mgr:    conn.NewManager(dialer, network, address, time.After, logger),
		logger: logger,
		quitc:  make(chan chan struct{}),
	}
	go e.loop(flushInterval)
	return e
}
Пример #2
0
func testEmitter() (*Emitter, *syncbuf) {
	buf := &syncbuf{buf: &bytes.Buffer{}}
	e := &Emitter{
		prefix:  "prefix.",
		mgr:     conn.NewManager(mockDialer(buf), "", "", time.After, log.NewNopLogger()),
		logger:  log.NewNopLogger(),
		keyVals: make(chan keyVal),
		quitc:   make(chan chan struct{}),
	}
	go e.loop(time.Millisecond * 20)
	return e, buf
}