本文整理匯總了Golang中github.com/mozilla-services/heka/pipeline.PluginHelper.StopDecoderRunner方法的典型用法代碼示例。如果您正苦於以下問題:Golang PluginHelper.StopDecoderRunner方法的具體用法?Golang PluginHelper.StopDecoderRunner怎麽用?Golang PluginHelper.StopDecoderRunner使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mozilla-services/heka/pipeline.PluginHelper
的用法示例。
在下文中一共展示了PluginHelper.StopDecoderRunner方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Run
func (lsi *LogstreamInput) Run(ir p.InputRunner, h p.PluginHelper, stopChan chan chan bool,
dRunner p.DecoderRunner) {
var (
parser func(ir p.InputRunner, deliver Deliver, stop chan chan bool) error
err error
)
if lsi.parseFunction == "payload" {
parser = lsi.payloadParser
} else if lsi.parseFunction == "messageProto" {
parser = lsi.messageProtoParser
}
var deliver func(*p.PipelinePack)
// Setup our pack delivery function appropriately for the configuration.
if dRunner == nil {
deliver = func(pack *p.PipelinePack) {
ir.Inject(pack)
}
} else {
inChan := dRunner.InChan()
deliver = func(pack *p.PipelinePack) {
inChan <- pack
}
}
// Check for more data interval
interval, _ := time.ParseDuration("250ms")
tick := time.Tick(interval)
ok := true
for ok {
// Clear our error
err = nil
// Attempt to read as many as we can
err = parser(ir, deliver, stopChan)
// Save our position if the stream hasn't done so for us.
if err != io.EOF {
lsi.stream.SavePosition()
}
lsi.recordCount = 0
if err != nil && err != io.EOF {
ir.LogError(err)
}
// Did our parser func get stopped?
if lsi.stopped != nil {
ok = false
continue
}
// Wait for our next interval, stop if needed
select {
case lsi.stopped = <-stopChan:
ok = false
case <-tick:
continue
}
}
close(lsi.stopped)
if dRunner != nil {
h.StopDecoderRunner(dRunner)
}
}