本文整理汇总了Golang中loggregator/sinks.Sink.Run方法的典型用法代码示例。如果您正苦于以下问题:Golang Sink.Run方法的具体用法?Golang Sink.Run怎么用?Golang Sink.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类loggregator/sinks.Sink
的用法示例。
在下文中一共展示了Sink.Run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2:
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() {