-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Load report renderers/senders from config (#215)
* add code to look up Renderers and pass results to Senders * wip * improve documentation * remove unnecessary inner class * add mimeType() method to RenderedReport * remove architectural-playground comment and unused class * put type bounds on Renderer type arguments * update existing Job implementations to insert Injectors instead of ActorRefs * coalesce Senders and Renderers classes into ReportExecution; add methods&impl for RenderedReport; send to each Recipient separately * move getMimeType() method from RenderedReport to ReportFormat * javadoc * fix javadoc error * do not expose raw byte[] from RenderedReport * findbugs * add equals/hashCode/toString to some classes * make ReportExecution.execute throw IllegalArgumentException if it can't find a Renderer/Sender * fix case-conversion of enum names * add ReportExecutionTest * ReportExecution.execute: return new DefaultReportResult * use ConcurrentMap instead of Map when populating format->report map * eliminate one-line render() method * javadoc * tweak a couple toString() methods * rename parameter to Sender.send * nits * give RecipientType a name field instead of using CaseFormat conversion * checkstyle * ReportExecution.execute only throws asynchronously * use mimetype for format-classification; add ReportSource.getTypeName * typo * remove RecipientType.getName() in favor of .name() * make ReportSource.Visitor an abstract class instead of an interface * findbugs * findbugs * fix SuppressFBWarnings * merge conflicts * checkstyle * fixup * add config * wip -- tests, bugfix * partial rebase * bugfix * bugfix * use Jackson instead of Guice and everything is beautiful * findbugs, checkstyle * small pr comments * small pr comments * small pr comments * refactor, fix tests * fixup * undo unnecessary changes / Guicing * delete old version of renamed file * fixup * checkstyle * implement classes referred to by config * findbugs * guice * back to Guice * checkstyle * remove unused Jackson annotations * comment * make it okay if config has no reports section * cleanup * comment * remove unnecessary Guice registrations * rename config section reports->reporting * make SourceType an enum * checkstyle * findbugs
- Loading branch information
1 parent
3a58754
commit f837c95
Showing
13 changed files
with
441 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
app/com/arpnetworking/metrics/portal/reports/SourceType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2019 Dropbox, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.arpnetworking.metrics.portal.reports; | ||
|
||
/** | ||
* Mechanisms by which reports can be generated. | ||
* | ||
* @author Spencer Pearson (spencerpearson at dropbox dot com) | ||
*/ | ||
public enum SourceType { | ||
/** | ||
* A report generated from a web page. | ||
*/ | ||
WEB_PAGE, | ||
} |
43 changes: 43 additions & 0 deletions
43
app/com/arpnetworking/metrics/portal/reports/impl/EmailSender.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2019 Dropbox, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.arpnetworking.metrics.portal.reports.impl; | ||
|
||
import com.arpnetworking.metrics.portal.reports.RenderedReport; | ||
import com.arpnetworking.metrics.portal.reports.Sender; | ||
import com.google.common.collect.ImmutableMap; | ||
import models.internal.reports.Recipient; | ||
import models.internal.reports.ReportFormat; | ||
|
||
import java.util.concurrent.CompletionStage; | ||
|
||
/** | ||
* Sends reports over email. | ||
* | ||
* @author Spencer Pearson (spencerpearson at dropbox dot com) | ||
*/ | ||
public class EmailSender implements Sender { | ||
@Override | ||
public CompletionStage<Void> send( | ||
final Recipient recipient, | ||
final ImmutableMap<ReportFormat, RenderedReport> formatsToSend | ||
) { | ||
throw new RuntimeException(); | ||
} | ||
|
||
EmailSender() {} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
app/com/arpnetworking/metrics/portal/reports/impl/chrome/BaseScreenshotRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2019 Dropbox, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.arpnetworking.metrics.portal.reports.impl.chrome; | ||
|
||
import com.arpnetworking.metrics.portal.reports.RenderedReport; | ||
import com.arpnetworking.metrics.portal.reports.Renderer; | ||
import models.internal.impl.DefaultRenderedReport; | ||
import models.internal.impl.WebPageReportSource; | ||
import models.internal.reports.ReportFormat; | ||
|
||
import java.time.Instant; | ||
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.CompletionStage; | ||
|
||
/** | ||
* Common code for renderers that use Chrome to load and scrape pages. | ||
* | ||
* @author Spencer Pearson (spencerpearson at dropbox dot com) | ||
*/ | ||
/* package private */ abstract class BaseScreenshotRenderer<F extends ReportFormat> implements Renderer<WebPageReportSource, F> { | ||
|
||
protected abstract byte[] getPageContent(WebPageReportSource source, F format, Object todo); | ||
|
||
@Override | ||
public CompletionStage<RenderedReport> render( | ||
final WebPageReportSource source, | ||
final F format, | ||
final Instant scheduled | ||
) { | ||
return CompletableFuture.completedFuture(new DefaultRenderedReport.Builder() | ||
.setScheduledFor(scheduled) | ||
.setGeneratedAt(Instant.now()) | ||
.setFormat(format) | ||
.build() // TODO(spencerpearson) | ||
); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/com/arpnetworking/metrics/portal/reports/impl/chrome/HtmlScreenshotRenderer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2019 Dropbox, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.arpnetworking.metrics.portal.reports.impl.chrome; | ||
|
||
import models.internal.impl.HtmlReportFormat; | ||
import models.internal.impl.WebPageReportSource; | ||
|
||
/** | ||
* Uses a headless Chrome instance to capture a page. | ||
* | ||
* @author Spencer Pearson (spencerpearson at dropbox dot com) | ||
*/ | ||
public final class HtmlScreenshotRenderer extends BaseScreenshotRenderer<HtmlReportFormat> { | ||
@Override | ||
protected byte[] getPageContent(final WebPageReportSource source, final HtmlReportFormat format, final Object todo) { | ||
return new byte[0]; // TODO(spencerpearson) | ||
} | ||
} |
Oops, something went wrong.