本文整理匯總了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() {