func (e *ElasticWReport) Start() (*models.Report, error) {
	timePrefix := time.Now().Format(`2006-01-02`)
	e.indexName = IndexNamePrefix + timePrefix
	nr := models.NewReport()
	response, err := e.client.Index().Index(e.indexName).Type(TypoReportName).BodyJson(nr).Do()
	if err != nil {
		return nil, err
	}
	e.rid = response.Id
	nr.Name = TypoReportName + `-` + response.Id
	_, err = e.client.Index().Index(e.indexName).Type(TypoReportName).BodyJson(nr).Id(response.Id).Do()
	if err != nil {
		return nil, err
	}
	return nr, nil
}
Exemple #2
0
func (m *MemWriter) Start() (*models.Report, error) {
	nr := models.NewReport()
	nr.Name = "mem-" + strconv.Itoa(nr.Created.Nanosecond())
	m.reports = append(m.reports, nr)
	return nr, nil
}