當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Sink.Identifier方法代碼示例

本文整理匯總了Golang中loggregator/sinks.Sink.Identifier方法的典型用法代碼示例。如果您正苦於以下問題:Golang Sink.Identifier方法的具體用法?Golang Sink.Identifier怎麽用?Golang Sink.Identifier使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在loggregator/sinks.Sink的用法示例。


在下文中一共展示了Sink.Identifier方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Delete

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
}
開發者ID:nkuacac,項目名稱:loggregator,代碼行數:11,代碼來源:grouped_sinks.go

示例2: Register

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
}
開發者ID:uabassguy,項目名稱:loggregator,代碼行數:18,代碼來源:grouped_sinks.go

示例3: Register

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
}
開發者ID:nkuacac,項目名稱:loggregator,代碼行數:20,代碼來源:grouped_sinks.go

示例4: Delete

func (gc *GroupedSinks) Delete(sink sinks.Sink) {
	gc.Lock()
	defer gc.Unlock()

	delete(gc.apps[sink.AppId()], sink.Identifier())
}
開發者ID:uabassguy,項目名稱:loggregator,代碼行數:6,代碼來源:grouped_sinks.go

示例5: UnregisterSink

func (sinkManager *SinkManager) UnregisterSink(sink sinks.Sink) {
	sinkManager.sinks.Delete(sink)
	close(sink.Channel())

	sinkManager.Metrics.Dec(sink)

	if syslogSink, ok := sink.(*sinks.SyslogSink); ok {
		syslogSink.Disconnect()
	}

	sinkManager.logger.Infof("SinkManager: Sink with channel %v and identifier %s requested closing. Closed it.", sink.Channel(), sink.Identifier())
}
開發者ID:james-masson,項目名稱:loggregator,代碼行數:12,代碼來源:sink_manager.go

示例6: RegisterSink

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
}
開發者ID:nkuacac,項目名稱:loggregator,代碼行數:21,代碼來源:sink_manager.go

示例7: unregisterSink

func (messageRouter *messageRouter) unregisterSink(s sinks.Sink, activeSinks *groupedsinks.GroupedSinks) {
	messageRouter.Lock()
	defer messageRouter.Unlock()

	activeSinks.Delete(s)
	close(s.Channel())
	switch s.(type) {
	case *sinks.DumpSink:
		messageRouter.activeDumpSinksCounter--
	case *sinks.SyslogSink:
		syslogSink, _ := s.(*sinks.SyslogSink)
		syslogSink.Disconnect()
		messageRouter.activeSyslogSinksCounter--
	case *sinks.WebsocketSink:
		messageRouter.activeWebsocketSinksCounter--
	}
	messageRouter.logger.Infof("MessageRouter: Sink with channel %v and identifier %s requested closing. Closed it.", s.Channel(), s.Identifier())
}
開發者ID:pxie,項目名稱:loggregator,代碼行數:18,代碼來源:message_router.go


注:本文中的loggregator/sinks.Sink.Identifier方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。