Skip to content

Commit

Permalink
Move this logic
Browse files Browse the repository at this point in the history
It used to make sense for this to live in the ingest service, because
we avoided allocating an ingest document if the pipeline was
empty. Now we already have the document regardless, so this can just
live in IngestDocument anyway.

In any case, this would be a rare and unusual thing to have happen at
all. I don't want to drop the logic completely, but I'm also not
worried about the performance implications of where it lives.
  • Loading branch information
joegallo committed Jan 27, 2023
1 parent 887ee71 commit c2fbb08
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,12 @@ private static Set<String> getAllFields(Map<String, Object> input, String prefix
* @param handler handles the result or failure
*/
public void executePipeline(Pipeline pipeline, BiConsumer<IngestDocument, Exception> handler) {
// shortcut if the pipeline is empty
if (pipeline.getProcessors().isEmpty()) {
handler.accept(this, null);
return;
}

if (executedPipelines.add(pipeline.getId())) {
Object previousPipeline = ingestMetadata.put("pipeline", pipeline.getId());
pipeline.execute(this, (result, e) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -907,11 +907,6 @@ static String getProcessorName(Processor processor) {
}

private void innerExecute(final IngestDocument ingestDocument, final Pipeline pipeline, final BiConsumer<Boolean, Exception> handler) {
if (pipeline.getProcessors().isEmpty()) {
handler.accept(true, null);
return;
}

ingestDocument.executePipeline(pipeline, (result, e) -> {
if (e != null) {
handler.accept(true, e);
Expand Down

0 comments on commit c2fbb08

Please sign in to comment.