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


Golang Selector.Select方法代碼示例

本文整理匯總了Golang中github.com/elastic/beats/libbeat/outputs/outil.Selector.Select方法的典型用法代碼示例。如果您正苦於以下問題:Golang Selector.Select方法的具體用法?Golang Selector.Select怎麽用?Golang Selector.Select使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/elastic/beats/libbeat/outputs/outil.Selector的用法示例。


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

示例1: eventIngestBulkMeta

func eventIngestBulkMeta(
	index outil.Selector,
	pipelineSel *outil.Selector,
	data outputs.Data,
) interface{} {
	type bulkMetaIndex struct {
		Index    string `json:"_index"`
		DocType  string `json:"_type"`
		Pipeline string `json:"pipeline"`
	}
	type bulkMeta struct {
		Index bulkMetaIndex `json:"index"`
	}

	event := data.Event
	pipeline, _ := pipelineSel.Select(event)
	if pipeline == "" {
		return eventBulkMeta(index, nil, data)
	}

	return bulkMeta{
		Index: bulkMetaIndex{
			Index:    getIndex(event, index),
			Pipeline: pipeline,
			DocType:  event["type"].(string),
		},
	}
}
開發者ID:YaSuenag,項目名稱:hsbeat,代碼行數:28,代碼來源:client.go

示例2: publishEventsBulk

func publishEventsBulk(conn redis.Conn, key outil.Selector, command string) publishFn {
	// XXX: requires key.IsConst() == true
	dest, _ := key.Select(common.MapStr{})
	return func(_ outil.Selector, data []outputs.Data) ([]outputs.Data, error) {
		args := make([]interface{}, 1, len(data)+1)
		args[0] = dest

		data, args = serializeEvents(args, 1, data)
		if (len(args) - 1) == 0 {
			return nil, nil
		}

		// RPUSH returns total length of list -> fail and retry all on error
		_, err := conn.Do(command, args...)
		if err != nil {
			logp.Err("Failed to %v to redis list (%v) with %v", command, err)
			return data, err
		}

		return nil, nil
	}
}
開發者ID:YaSuenag,項目名稱:hsbeat,代碼行數:22,代碼來源:client.go

示例3: getIndex

// getIndex returns the full index name
// Index is either defined in the config as part of the output
// or can be overload by the event through setting index
func getIndex(event common.MapStr, index outil.Selector) string {

	ts := time.Time(event["@timestamp"].(common.Time)).UTC()

	// Check for dynamic index
	// XXX: is this used/needed?
	if _, ok := event["beat"]; ok {
		beatMeta, ok := event["beat"].(common.MapStr)
		if ok {
			// Check if index is set dynamically
			if dynamicIndex, ok := beatMeta["index"]; ok {
				if dynamicIndexValue, ok := dynamicIndex.(string); ok {
					return fmt.Sprintf("%s-%d.%02d.%02d",
						dynamicIndexValue, ts.Year(), ts.Month(), ts.Day())
				}
			}
		}
	}

	str, _ := index.Select(event)
	return str
}
開發者ID:YaSuenag,項目名稱:hsbeat,代碼行數:25,代碼來源:client.go


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