Пример #1
0
func (c *collector) source(ins *visor.Instance) {
	logFile := path.Join(c.logDir, ins.WorkerID(), "current")
	t, err := NewFileTail(logFile)
	if err != nil {
		c.errc <- fmt.Errorf("collector: unable to source %d: %s", ins.ID, err)
		return
	}
	s := NewSource(ins, t, c.pubc)

	c.Add(s, t)
	logf("collector: created source %d", ins.ID)

	if err := <-s.Error(); err != nil {
		c.errc <- err
		return
	}

	c.lookup.Remove(s)
	logf("collector: removed source %d", ins.ID)
}
Пример #2
0
func NewSource(ins *visor.Instance, tail Tailer, pubc chan<- Line) Source {
	s := &source{
		ins:        ins,
		errc:       make(chan error, 1),
		waitc:      make(chan error),
		stopc:      make(chan chan error),
		instanceID: strconv.FormatInt(ins.ID, 10),
		topics: []string{
			ins.ServiceName(),
			ins.RevString(),
			ins.EnvString(),
			ins.RefString(),
		},
	}

	go s.waitStop()
	go s.loop(tail, pubc)

	return s
}