本文整理匯總了Golang中github.com/mozilla-services/heka/pipeline.FilterRunner.UpdateCursor方法的典型用法代碼示例。如果您正苦於以下問題:Golang FilterRunner.UpdateCursor方法的具體用法?Golang FilterRunner.UpdateCursor怎麽用?Golang FilterRunner.UpdateCursor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mozilla-services/heka/pipeline.FilterRunner
的用法示例。
在下文中一共展示了FilterRunner.UpdateCursor方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Run
func (this *SandboxManagerFilter) Run(fr pipeline.FilterRunner,
h pipeline.PluginHelper) (err error) {
inChan := fr.InChan()
var ok = true
var pack *pipeline.PipelinePack
var delta int64
this.restoreSandboxes(fr, h, this.workingDirectory)
for ok {
select {
case pack, ok = <-inChan:
if !ok {
break
}
atomic.AddInt64(&this.processMessageCount, 1)
delta = time.Now().UnixNano() - pack.Message.GetTimestamp()
if math.Abs(float64(delta)) >= 5e9 {
fr.UpdateCursor(pack.QueueCursor)
pack.Recycle(fmt.Errorf("Discarded control message: %d seconds skew",
delta/1e9))
break
}
action, _ := pack.Message.GetFieldValue("action")
switch action {
case "load":
current := int(atomic.LoadInt32(&this.currentFilters))
if current < this.maxFilters {
err := this.loadSandbox(fr, h, this.workingDirectory, pack.Message)
if err != nil {
p, e := h.PipelinePack(0)
if e != nil {
fr.LogError(err)
fr.LogError(fmt.Errorf("can't send termination message: %s", e.Error()))
break
}
p.Message.SetType("heka.sandbox-terminated")
p.Message.SetLogger(pipeline.HEKA_DAEMON)
message.NewStringField(p.Message, "plugin", fr.Name())
p.Message.SetPayload(err.Error())
fr.Inject(p)
fr.LogError(err)
}
} else {
fr.LogError(fmt.Errorf("%s attempted to load more than %d filters",
fr.Name(), this.maxFilters))
}
case "unload":
fv, _ := pack.Message.GetFieldValue("name")
if name, ok := fv.(string); ok {
name = getSandboxName(fr.Name(), name)
if this.pConfig.RemoveFilterRunner(name) {
removeAll(this.workingDirectory, fmt.Sprintf("%s.*", name))
}
}
}
pack.Recycle(nil)
}
}
return
}