From 160ba8efa0c6c3689b50e0b4c3c9d05ca0077c62 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 31 Jul 2017 09:31:46 +0100 Subject: [PATCH 1/2] rename 'report_persistence' capability to 'historic_reports' since that better captures the intent - the UI doesn't care about reports get stored, but what reports it can retrieve. --- common/xfer/constants.go | 6 +++--- prog/app.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/xfer/constants.go b/common/xfer/constants.go index 04f151699..7b3c0469e 100644 --- a/common/xfer/constants.go +++ b/common/xfer/constants.go @@ -14,9 +14,9 @@ const ( ScopeProbeVersionHeader = "X-Scope-Probe-Version" ) -// ReportPersistenceCapability indicates whether probe reports end up in a -// long-term storage and can be retrieved. -const ReportPersistenceCapability = "report_persistence" +// HistoricReportsCapability indicates whether reports older than the +// current time (-app.window) can be retrieved. +const HistoricReportsCapability = "historic_reports" // Details are some generic details that can be fetched from /api type Details struct { diff --git a/prog/app.go b/prog/app.go index 618c36a2c..ecd4df48e 100644 --- a/prog/app.go +++ b/prog/app.go @@ -295,7 +295,7 @@ func appMain(flags appFlags) { } capabilities := map[string]bool{ - xfer.ReportPersistenceCapability: flags.s3URL != "local", + xfer.HistoricReportsCapability: flags.s3URL != "local", } handler := router(collector, controlRouter, pipeRouter, flags.externalUI, capabilities) if flags.logHTTP { From 1f95e3efd4f4912c643fbdb43e98c22377b73693 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Mon, 31 Jul 2017 09:58:31 +0100 Subject: [PATCH 2/2] obtain historic_reports capability from Reporter --- app/collector.go | 13 +++++++++++++ app/multitenant/aws_collector.go | 4 ++++ prog/app.go | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/app/collector.go b/app/collector.go index 03319cdf0..d4b97dc6c 100644 --- a/app/collector.go +++ b/app/collector.go @@ -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 } diff --git a/app/multitenant/aws_collector.go b/app/multitenant/aws_collector.go index 9bba88633..964b5b241 100644 --- a/app/multitenant/aws_collector.go +++ b/app/multitenant/aws_collector.go @@ -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)) diff --git a/prog/app.go b/prog/app.go index ecd4df48e..5b06948d4 100644 --- a/prog/app.go +++ b/prog/app.go @@ -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 {