func()

in internal/task_request/task_request.go [168:201]


func (h *taskRequestTimer) buildRequestPayload() ([]byte, error) {
	d, err := disk_stats.DiskUsage(h.indexDir)
	if err != nil {
		return []byte{}, err
	}

	inProgressCount := strconv.Itoa(h.indexingLock.InProgressCount())

	params := map[string]interface{}{
		"node.url":         h.selfURL,
		"node.search_url":  h.searchURL,
		"node.name":        h.nodeName,
		"node.version":     h.version,
		"node.task_count":  inProgressCount,
		"node.concurrency": strconv.Itoa(h.concurrency),
		"disk.all":         strconv.FormatUint(d.All, 10),
		"disk.free":        strconv.FormatUint(d.Free, 10),
		"disk.used":        strconv.FormatUint(d.Used, 10),
	}

	if d.Indexed == -1 {
		params["error"] = "Error in calculating disk.indexed"
	} else {
		params["disk.indexed"] = strconv.FormatInt(d.Indexed, 10)
	}

	payload, err := json.Marshal(params)

	if err != nil {
		return []byte{}, err
	}

	return payload, nil
}