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


Golang PluginHelper.StopDecoderRunner方法代碼示例

本文整理匯總了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)
	}
}
開發者ID:salekseev,項目名稱:heka,代碼行數:68,代碼來源:logstreamer_input.go


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