Skip to content

Commit

Permalink
PDF: Switch to using Proton
Browse files Browse the repository at this point in the history
We are sunsetting Electron and switchng fully to Proton. Therefore,
adjust the code to use Proton only if `new_uri` is specified (and
consequently get rid of `new_probability` and `new_pdf`). However, for
the sake of backwards compatibility, keep the code using Electron
around.

Bug: T210651
  • Loading branch information
Marko Obrovac committed Dec 20, 2018
1 parent 5d672cb commit 4818c45
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 19 deletions.
4 changes: 0 additions & 4 deletions config.example.wikimedia.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,7 @@ default_project: &default_project
pdf:
# Cache PDF for 5 minutes since it's not purged
cache_control: s-maxage=600, max-age=600
uri: https://pdfrender-beta.wmflabs.org
new_uri: https://proton-beta.wmflabs.org
new_probability: 1
secret: secret
scheme: https
transform:
cx_host: https://cxserver-beta.wmflabs.org
skip_updates: false
Expand Down
2 changes: 0 additions & 2 deletions config.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ default_project: &default_project
pdf:
# Cache PDF for 5 minutes since it's not purged
cache_control: s-maxage=600, max-age=600
uri: https://pdfrender-beta.wmflabs.org
new_uri: https://proton-beta.wmflabs.org
secret: secret
transform:
cx_host: https://cxserver-beta.wmflabs.org
skip_updates: false
Expand Down
16 changes: 3 additions & 13 deletions v1/pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,13 @@ module.exports = options => ({
operations: {
generatePDF: (hyper, req) => {
const rp = req.params;
const newProbability = options.new_probability || 0;
return hyper.get(new URI([rp.domain, 'sys', 'page_revisions', 'page', rp.title]))
.then((latestRevision) => {
if (options.new_uri && (Math.random() < newProbability || req.query.new_pdf)) {
const newResult = hyper.get(new URI(
if (options.new_uri) {
return hyper.get(new URI(
`${options.new_uri}/${rp.domain}/v1/`
+ `pdf/${encodeURIComponent(rp.title)}/a4/desktop`
))
.catch((e) => {
hyper.logger.log('error/proton', e);
if (req.query.new_pdf) {
throw e;
}
});
if (req.query.new_pdf) {
return newResult;
}
));
}
return hyper.get({
uri: new URI(`${options.uri}/pdf`),
Expand Down

0 comments on commit 4818c45

Please sign in to comment.