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


Golang mb.EventsFetcher類代碼示例

本文整理匯總了Golang中github.com/elastic/beats/metricbeat/mb.EventsFetcher的典型用法代碼示例。如果您正苦於以下問題:Golang EventsFetcher類的具體用法?Golang EventsFetcher怎麽用?Golang EventsFetcher使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了EventsFetcher類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: multiEventFetch

func (msw *metricSetWrapper) multiEventFetch(fetcher mb.EventsFetcher) ([]common.MapStr, error) {
	start := time.Now()
	events, err := fetcher.Fetch()
	elapsed := time.Since(start)

	var rtnEvents []common.MapStr
	if err == nil {
		msw.stats.Add(successesKey, 1)

		for _, event := range events {
			event, err = createEvent(msw, event, nil, start, elapsed)
			if err != nil {
				return nil, errors.Wrap(err, "createEvent failed")
			}
			rtnEvents = append(rtnEvents, event)
		}
	} else {
		msw.stats.Add(failuresKey, 1)

		event, err := createEvent(msw, nil, err, start, elapsed)
		if err != nil {
			return nil, errors.Wrap(err, "createEvent failed")
		}
		rtnEvents = append(rtnEvents, event)
	}

	return rtnEvents, nil
}
開發者ID:mrkschan,項目名稱:beats,代碼行數:28,代碼來源:module.go

示例2: multiEventFetch

func (msw *metricSetWrapper) multiEventFetch(fetcher mb.EventsFetcher, host string) error {
	start := time.Now()
	events, err := fetcher.Fetch(host)
	elapsed := time.Since(start)
	if err == nil {
		msw.stats.Add(successesKey, 1)

		for _, event := range events {
			event, err = createEvent(msw, host, event, nil, start, elapsed)
			if err != nil {
				logp.Warn("createEvent error: %v", err)
			}

			if event != nil {
				msw.module.pubClient.PublishEvent(event)
				msw.stats.Add(eventsKey, 1)
			}
		}
	} else {
		msw.stats.Add(failuresKey, 1)

		event, err := createEvent(msw, host, nil, err, start, elapsed)
		if err != nil {
			logp.Warn("createEvent error: %v", err)
		}

		if event != nil {
			msw.module.pubClient.PublishEvent(event)
			msw.stats.Add(eventsKey, 1)
		}
	}

	return nil
}
開發者ID:yan2jared,項目名稱:beats,代碼行數:34,代碼來源:module.go

示例3: WriteEvents

func WriteEvents(f mb.EventsFetcher, t *testing.T) error {

	if !*dataFlag {
		t.Skip("Skip data generation tests")
	}
	events, err := f.Fetch()
	if err != nil {
		return err
	}

	return createEvent(events[0], f)
}
開發者ID:ruflin,項目名稱:beats,代碼行數:12,代碼來源:data_generator.go


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