obtain historic_reports capability from Reporter

This commit is contained in:
Matthias Radestock
2017-07-31 09:58:31 +01:00
parent 160ba8efa0
commit 1f95e3efd4
3 changed files with 18 additions and 1 deletions

View File

@@ -29,6 +29,7 @@ const reportQuantisationInterval = 3 * time.Second
// interface for parts of the app, and several experimental components.
type Reporter interface {
Report(context.Context, time.Time) (report.Report, error)
HasHistoricReports() bool
WaitOn(context.Context, chan struct{})
UnWait(context.Context, chan struct{})
}
@@ -139,6 +140,12 @@ func (c *collector) Report(_ context.Context, timestamp time.Time) (report.Repor
return rpt, nil
}
// HasHistoricReports indicates whether the collector contains reports
// older than now-app.window.
func (c *collector) HasHistoricReports() bool {
return false
}
// remove reports older than the app.window
func (c *collector) clean() {
var (
@@ -195,6 +202,12 @@ func (c StaticCollector) Report(context.Context, time.Time) (report.Report, erro
return report.Report(c), nil
}
// HasHistoricReports indicates whether the collector contains reports
// older than now-app.window.
func (c StaticCollector) HasHistoricReports() bool {
return false
}
// Add adds a report to the collector's internal state. It implements Adder.
func (c StaticCollector) Add(context.Context, report.Report, []byte) error { return nil }

View File

@@ -340,6 +340,10 @@ func (c *awsCollector) Report(ctx context.Context, timestamp time.Time) (report.
return c.merger.Merge(reports).Upgrade(), nil
}
func (c *awsCollector) HasHistoricReports() bool {
return true
}
// calculateDynamoKeys generates the row & column keys for Dynamo.
func calculateDynamoKeys(userid string, now time.Time) (string, string) {
rowKey := fmt.Sprintf("%s-%s", userid, strconv.FormatInt(now.UnixNano()/time.Hour.Nanoseconds(), 10))

View File

@@ -295,7 +295,7 @@ func appMain(flags appFlags) {
}
capabilities := map[string]bool{
xfer.HistoricReportsCapability: flags.s3URL != "local",
xfer.HistoricReportsCapability: collector.HasHistoricReports(),
}
handler := router(collector, controlRouter, pipeRouter, flags.externalUI, capabilities)
if flags.logHTTP {