コード例 #1
0
func (messageRouter *messageRouter) Start() {
	activeSinks := groupedsinks.NewGroupedSinks()

	for {
		select {
		case dr := <-messageRouter.dumpReceiverChan:
			if sink := activeSinks.DumpFor(dr.appId); sink != nil {
				sink.Dump(dr.outputChannel)
			}
		case s := <-messageRouter.sinkOpenChan:
			messageRouter.registerSink(s, activeSinks)
		case s := <-messageRouter.sinkCloseChan:
			messageRouter.unregisterSink(s, activeSinks)
		case receivedMessage := <-messageRouter.parsedMessageChan:
			messageRouter.logger.Debugf("MessageRouter: Received %d bytes of data from agent listener.", receivedMessage.GetRawMessageLength())

			//drain management
			appId := receivedMessage.GetLogMessage().GetAppId()
			messageRouter.manageDrains(activeSinks, appId, receivedMessage.GetLogMessage().GetDrainUrls(), receivedMessage.GetLogMessage().GetSourceType())
			messageRouter.manageDumps(activeSinks, appId)

			//send to drains and sinks
			messageRouter.logger.Debugf("MessageRouter: Searching for sinks with appId [%s].", appId)
			for _, s := range activeSinks.For(appId) {
				messageRouter.logger.Debugf("MessageRouter: Sending Message to channel %v for sinks targeting [%s].", s.Identifier(), appId)
				s.Channel() <- receivedMessage
			}
			messageRouter.logger.Debugf("MessageRouter: Done sending message to tail clients.")
		}
	}
}
コード例 #2
0
func NewSinkManager(maxRetainedLogMessages uint32, skipCertVerify bool, blackListManager *blacklist.URLBlacklistManager, logger *gosteno.Logger) (*SinkManager, <-chan domain.AppServices) {
	appStoreUpdateChan := make(chan domain.AppServices, 10)
	return &SinkManager{
		doneChannel:         make(chan struct{}),
		errorChannel:        make(chan *logmessage.Message, 100),
		urlBlacklistManager: blackListManager,
		sinks:               groupedsinks.NewGroupedSinks(),
		skipCertVerify:      skipCertVerify,
		recentLogCount:      maxRetainedLogMessages,
		Metrics:             metrics.NewSinkManagerMetrics(),
		logger:              logger,
		appStoreUpdateChan:  appStoreUpdateChan,
	}, appStoreUpdateChan
}
コード例 #3
0
func NewSinkManager(maxRetainedLogMessages int, skipCertVerify bool, blackListIPs []iprange.IPRange, logger *gosteno.Logger) *SinkManager {
	return &SinkManager{
		sinkOpenChan:  make(chan sinks.Sink, 20),
		sinkCloseChan: make(chan sinks.Sink, 20),
		errorChannel:  make(chan *logmessage.Message, 100),
		urlBlacklistManager: &URLBlacklistManager{
			blacklistIPs: blackListIPs,
		},
		sinks:          groupedsinks.NewGroupedSinks(),
		skipCertVerify: skipCertVerify,
		recentLogCount: maxRetainedLogMessages,
		Metrics:        NewSinkManagerMetrics(),
		logger:         logger,
	}
}
コード例 #4
0
}

func (c *TestSink) Identifier() string        { return c.identifier }
func (c *TestSink) ShouldReceiveErrors() bool { return true }
func (c *TestSink) Emit() instrumentation.Context {
	return instrumentation.Context{}
}

var _ = Describe("GroupedSink", func() {
	var fakeTimeProvider *faketimeprovider.FakeTimeProvider
	var groupedSinks *groupedsinks.GroupedSinks
	var inputChan, errorChan chan *logmessage.Message

	BeforeEach(func() {
		fakeTimeProvider = faketimeprovider.New(time.Now())
		groupedSinks = groupedsinks.NewGroupedSinks()
		inputChan = make(chan *logmessage.Message)
		errorChan = make(chan *logmessage.Message)

	})

	Describe("BroadCast", func() {
		It("should send message to all registered sinks that match the appId", func(done Done) {
			appId := "123"
			appSink := syslog.NewSyslogSink("123", "url", loggertesthelper.Logger(), DummySyslogWriter{}, errorChan)
			otherInputChan := make(chan *logmessage.Message)
			groupedSinks.Register(otherInputChan, appSink)

			appId = "789"
			appSink = syslog.NewSyslogSink(appId, "url", loggertesthelper.Logger(), DummySyslogWriter{}, errorChan)