Markdown interface across service boundary.

This commit is contained in:
David Russell 2017-10-31 10:04:38 +07:00
parent 248b91bc07
commit 13dad55e16
2 changed files with 8 additions and 7 deletions

View File

@ -26,7 +26,7 @@ package com.gitpitch.controllers;
import com.gitpitch.git.GRS;
import com.gitpitch.git.GRSManager;
import com.gitpitch.models.GitRepoModel;
import com.gitpitch.models.MarkdownModel;
import com.gitpitch.models.Markdown;
import com.gitpitch.executors.FrontEndThreads;
import com.gitpitch.models.SlideshowModel;
import com.gitpitch.services.PitchService;
@ -207,11 +207,11 @@ public class PitchController extends Controller {
PitchParams pp =
PitchParams.build(grsOnCall(grs),
user, repo, branch, null, pitchme);
Optional<MarkdownModel> mdmo = pitchService.cachedMarkdown(pp);
Optional<Markdown> mdmo = pitchService.cachedMarkdown(pp);
if (mdmo.isPresent()) {
MarkdownModel mdm = mdmo.get();
Markdown mdm = mdmo.get();
log.info("markdown: [ mdwn, cached, online ] {}", pp);
return CompletableFuture.completedFuture(ok(mdm.produce())
.as("text/markdown"));

View File

@ -24,6 +24,7 @@
package com.gitpitch.services;
import com.gitpitch.models.GitRepoModel;
import com.gitpitch.models.Markdown;
import com.gitpitch.models.MarkdownModel;
import com.gitpitch.models.SlideshowModel;
import com.gitpitch.policies.CacheTimeout;
@ -150,7 +151,7 @@ public class PitchService {
/*
* Return cached MarkdownModel, else Optional.empty.
*/
public Optional<MarkdownModel> cachedMarkdown(PitchParams pp) {
public Optional<Markdown> cachedMarkdown(PitchParams pp) {
String mdmKey = MarkdownModel.genKey(pp);
return Optional.ofNullable(pitchCache.get(mdmKey));
@ -159,7 +160,7 @@ public class PitchService {
/*
* Return RepoModel.
*/
public MarkdownModel fetchMarkdown(PitchParams pp) {
public Markdown fetchMarkdown(PitchParams pp) {
log.debug("fetchMarkdown: pp={}", pp);
CountDownLatch markdownLatch = gitService.fetchMarkdown(pp);
@ -177,8 +178,8 @@ public class PitchService {
log.warn("fetchMarkdown: pp={}, markdownLatch.await ex={}", pp, ex);
}
Optional<MarkdownModel> mdmo = cachedMarkdown(pp);
MarkdownModel mdm = mdmo.orElse(null);
Optional<Markdown> mdmo = cachedMarkdown(pp);
Markdown mdm = mdmo.orElse(null);
log.debug("fetchMarkdown: pp={}, returning mdm={}", pp, mdm);
return mdm;