예제 #1
0
func (sinkManager *SinkManager) RegisterSink(sink sinks.Sink) bool {
	inputChan := make(chan *logmessage.Message)
	ok := sinkManager.sinks.Register(inputChan, sink)
	if !ok {
		return false
	}

	sinkManager.Metrics.Inc(sink)

	sinkManager.logger.Debugf("SinkManager: Sink with identifier %v requested. Opened it.", sink.Identifier())

	go func() {
		sink.Run(inputChan)
		sinkManager.UnregisterSink(sink)
	}()

	return true
}
예제 #2
0
func (sinkManager *SinkManager) RegisterSink(sink sinks.Sink, block ...bool) bool {
	inputChan := make(chan *logmessage.Message)
	ok := sinkManager.sinks.Register(inputChan, sink)
	if !ok {
		return false
	}

	sinkManager.Metrics.Inc(sink)

	sinkManager.logger.Infof("SinkManager: Sink with identifier %v requested. Opened it.", sink.Identifier())
	if len(block) > 0 {
		sink.Run(inputChan)
		sinkManager.unregisterSink(sink)
	} else {
		go func() {
			sink.Run(inputChan)
			sinkManager.unregisterSink(sink)
		}()
	}
	return true
}
예제 #3
0
		syslogSink = sinks.NewSyslogSink("appId", "syslog://localhost:24632", loggertesthelper.Logger(), sysLogger, errorChannel)
	})

	AfterEach(func() {
		select {
		case <-sysLoggerDoneChan:
		default:
			closeSysLoggerDoneChan()
		}
	})

	Context("when remote syslog server is down", func() {
		BeforeEach(func() {
			sysLogger.SetDown(true)
			go func() {
				syslogSink.Run()
				closeSysLoggerDoneChan()
			}()
		})

		It("should still accept messages without blocking", func(done Done) {
			logMessage := NewMessage("test message", "appId")

			for i := 0; i < 100; i++ {
				syslogSink.Channel() <- logMessage
			}
			close(done)
		})

		Context("when remote syslog server comes up", func() {
			BeforeEach(func() {