当前位置: 首页>>代码示例>>Golang>>正文


Golang Sink.Channel方法代码示例

本文整理汇总了Golang中loggregator/sinks.Sink.Channel方法的典型用法代码示例。如果您正苦于以下问题:Golang Sink.Channel方法的具体用法?Golang Sink.Channel怎么用?Golang Sink.Channel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在loggregator/sinks.Sink的用法示例。


在下文中一共展示了Sink.Channel方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: RegisterSink

func (sinkManager *SinkManager) RegisterSink(sink sinks.Sink) bool {
	ok := sinkManager.sinks.Register(sink)
	if !ok {
		return false
	}

	sinkManager.Metrics.Inc(sink)

	sinkManager.logger.Infof("SinkManager: Sink with channel %v requested. Opened it.", sink.Channel())
	return true
}
开发者ID:james-masson,项目名称:loggregator,代码行数:11,代码来源:sink_manager.go

示例2: dumpToSink

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
	}
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:11,代码来源:message_router.go

示例3: 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

示例4: 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:
		messageRouter.activeSyslogSinksCounter--
	case *sinks.WebsocketSink:
		messageRouter.activeWebsocketSinksCounter--
	}
	messageRouter.logger.Infof("MessageRouter: Sink with channel %v requested closing. Closed it.", s.Channel())
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:16,代码来源:message_router.go

示例5:

	})

	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() {
				logMessage := NewMessage("test message", "appId")

				for i := 0; i < 5; i++ {
					syslogSink.Channel() <- logMessage
				}
				close(syslogSink.Channel())
				sysLogger.SetDown(false)
			})
开发者ID:james-masson,项目名称:loggregator,代码行数:30,代码来源:syslog_sink_test.go

示例6: registerSink

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

	ok := activeSinks.Register(s)
	switch s.(type) {
	case *sinks.DumpSink:
		messageRouter.activeDumpSinksCounter++
	case *sinks.SyslogSink:
		messageRouter.activeSyslogSinksCounter++
	case *sinks.WebsocketSink:
		messageRouter.activeWebsocketSinksCounter++
		go messageRouter.dumpToSink(s, activeSinks)
	}
	messageRouter.logger.Infof("MessageRouter: Sink with channel %v requested. Opened it.", s.Channel())
	return ok
}
开发者ID:uabassguy,项目名称:loggregator,代码行数:17,代码来源:message_router.go


注:本文中的loggregator/sinks.Sink.Channel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。