diff options
| author | Paul Buetow <pbuetow@mimecast.com> | 2024-02-26 10:45:54 +0200 |
|---|---|---|
| committer | Paul Buetow <pbuetow@mimecast.com> | 2024-03-29 17:16:53 +0200 |
| commit | da9c21a2f23b1ed4d469aa88681d404b778d1689 (patch) | |
| tree | 1ff51310dc2e001cf8aaf71c763023bba9f6656e /internal/clients | |
| parent | 0f718c963e118139c893e9c52092e278bcd3b396 (diff) | |
only rename .csv.tmp to .csv when the final result was written
Diffstat (limited to 'internal/clients')
| -rw-r--r-- | internal/clients/maprclient.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/internal/clients/maprclient.go b/internal/clients/maprclient.go index 2bc66a4..440cb91 100644 --- a/internal/clients/maprclient.go +++ b/internal/clients/maprclient.go @@ -101,7 +101,7 @@ func (c *MaprClient) Start(ctx context.Context, statsCh <-chan string) (status i status = c.baseClient.Start(ctx, statsCh) if c.cumulative { dlog.Client.Debug("Received final mapreduce result") - c.reportResults() + c.reportResults(true) } return @@ -145,16 +145,16 @@ func (c *MaprClient) periodicReportResults(ctx context.Context) { select { case <-time.After(c.query.Interval): dlog.Client.Debug("Gathering interim mapreduce result") - c.reportResults() + c.reportResults(false) case <-ctx.Done(): return } } } -func (c *MaprClient) reportResults() { +func (c *MaprClient) reportResults(finalResult bool) { if c.query.HasOutfile() { - c.writeResultsToOutfile() + c.writeResultsToOutfile(finalResult) return } c.printResults() @@ -208,14 +208,14 @@ func (c *MaprClient) printResults() { dlog.Client.Raw(fmt.Sprintf("%s\n", result)) } -func (c *MaprClient) writeResultsToOutfile() { +func (c *MaprClient) writeResultsToOutfile(finalResult bool) { if c.cumulative { - if err := c.globalGroup.WriteResult(c.query); err != nil { + if err := c.globalGroup.WriteResult(c.query, finalResult); err != nil { dlog.Client.FatalPanic(err) } return } - if err := c.globalGroup.SwapOut().WriteResult(c.query); err != nil { + if err := c.globalGroup.SwapOut().WriteResult(c.query, true); err != nil { dlog.Client.FatalPanic(err) } } |
