Exemple #1
0
func (gc *GroupedSinks) Delete(sink sinks.Sink) bool {
	gc.Lock()
	defer gc.Unlock()
	wrapper, ok := gc.apps[sink.AppId()][sink.Identifier()]
	if ok {
		close(wrapper.inputChan)
		delete(gc.apps[sink.AppId()], sink.Identifier())
		return true
	}
	return false
}
func (messageRouter *messageRouter) dumpToSink(sink sinks.Sink, activeSinks *groupedsinks.GroupedSinks) {
	dumpChan := make(chan *logmessage.Message, 20)
	if sink := activeSinks.DumpFor(sink.AppId()); sink != nil {
		sink.Dump(dumpChan)
	} else {
		close(dumpChan)
	}
	for message := range dumpChan {
		sink.Channel() <- message
	}
}
Exemple #3
0
func (sinkManager *SinkManager) UnregisterSink(sink sinks.Sink) {

	ok := sinkManager.sinks.CloseAndDelete(sink)
	if !ok {
		return
	}
	sinkManager.Metrics.Dec(sink)

	if syslogSink, ok := sink.(*syslog.SyslogSink); ok {
		syslogSink.Disconnect()
	} else if _, ok := sink.(*dump.DumpSink); ok {
		sinkManager.appStoreUpdateChan <- domain.AppServices{AppId: sink.AppId()}
	}

	sinkManager.logger.Debugf("SinkManager: Sink with identifier %s requested closing. Closed it.", sink.Identifier())
}
func (gc *GroupedSinks) Register(s sinks.Sink) bool {
	gc.Lock()
	defer gc.Unlock()

	appId := s.AppId()
	if appId == "" || s.Identifier() == "" {
		return false
	}
	if gc.apps[appId] == nil {
		gc.apps[appId] = make(map[string]sinks.Sink)
	}

	if gc.apps[appId][s.Identifier()] != nil {
		return false
	}
	gc.apps[appId][s.Identifier()] = s
	return true
}
Exemple #5
0
func (gc *GroupedSinks) Register(in chan<- *logmessage.Message, s sinks.Sink) bool {
	gc.Lock()
	defer gc.Unlock()

	appId := s.AppId()
	if appId == "" || s.Identifier() == "" {
		return false
	}
	sinksForApp := gc.apps[appId]
	if sinksForApp == nil {
		gc.apps[appId] = make(map[string]*sinkWrapper)
		sinksForApp = gc.apps[appId]
	}

	if _, ok := sinksForApp[s.Identifier()]; ok {
		return false
	}
	sinksForApp[s.Identifier()] = &sinkWrapper{inputChan: in, s: s}
	return true
}
func (gc *GroupedSinks) Delete(sink sinks.Sink) {
	gc.Lock()
	defer gc.Unlock()

	delete(gc.apps[sink.AppId()], sink.Identifier())
}