Skip to content

Commit

Permalink
perf(pipelines): Use new endpoint to fetch pipeline config (#733)
Browse files Browse the repository at this point in the history
The only call from echo to the front50 /pipelines/id/history
endpoint passes limit=1. Replace it with the new endpoint
/pipelines/id/get that gets the current state of the
pipeline config and does so more performantly than the
history endpoint.

Requires front50 >= 2.11.0, which is when this new endpoint
was added.
  • Loading branch information
ezimanyi authored and mergify[bot] committed Dec 16, 2019
1 parent 138686c commit 29c2b6a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ public interface Front50Service {
@Headers("Accept: application/json")
List<Pipeline> getPipelines(@Path("application") String application);

// either an empty list or a singleton of a raw pipeline config
@GET("/pipelines/{pipelineId}/history?limit=1")
List<Map<String, Object>> getLatestVersion(@Path("pipelineId") String pipelineId);
@GET("/pipelines/{pipelineId}/get")
Map<String, Object> getPipeline(@Path("pipelineId") String pipelineId);

@POST("/graphql")
@Headers("Accept: application/json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,24 +221,13 @@ private static Map<String, List<Trigger>> extractEnabledTriggersFrom(List<Pipeli
// if anything fails during the refresh, we fall back to returning the cached version
public Pipeline refresh(Pipeline cached) {
try {
List<Map<String, Object>> latestVersion = front50.getLatestVersion(cached.getId());
if (latestVersion.isEmpty()) {
// if that corresponds to the case where the pipeline has been deleted, maybe we should not
// return the
// cached version
log.warn(
"Got empty results back from front50's /pipelines/{}/history?limit=1, falling back to cached={}",
cached.getId(),
cached);
return cached;
}

Optional<Pipeline> processed = process(latestVersion.get(0));
Map<String, Object> pipeline = front50.getPipeline(cached.getId());
Optional<Pipeline> processed = process(pipeline);
if (!processed.isPresent()) {
log.warn(
"Failed to process raw pipeline, falling back to cached={}\n latestVersion={}",
cached,
latestVersion);
pipeline);
return cached;
}

Expand Down

0 comments on commit 29c2b6a

Please sign in to comment.