make ProcessorFactoryProvider extend BiFunction
This commit is contained in:
parent
635b9b5a46
commit
8251a50667
|
@ -21,14 +21,14 @@ package org.elasticsearch.ingest;
|
|||
|
||||
import org.elasticsearch.env.Environment;
|
||||
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
/**
|
||||
* The ingest framework (pipeline, processor and processor factory) can't rely on ES specific code. However some
|
||||
* processors rely on reading files from the config directory. We can't add Environment as a constructor parameter,
|
||||
* so we need some code that provides the physical location of the configuration directory to the processor factories
|
||||
* that need this and this is what this processor factory provider does.
|
||||
* Functional interface that allows to create a {@link org.elasticsearch.ingest.Processor.Factory} once all the needed
|
||||
* components are available at a later stage, more specifically the {@link Environment} and the {@link TemplateService}
|
||||
* which some processors need.
|
||||
*/
|
||||
//TODO this abstraction could be removed once ingest-core is part of es core?
|
||||
@FunctionalInterface
|
||||
public interface ProcessorFactoryProvider {
|
||||
Processor.Factory get(Environment environment, TemplateService templateService);
|
||||
public interface ProcessorFactoryProvider extends BiFunction<Environment, TemplateService, Processor.Factory> {
|
||||
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class PipelineStore extends AbstractComponent implements Closeable {
|
|||
Map<String, Processor.Factory> processorFactories = new HashMap<>();
|
||||
TemplateService templateService = new MustacheTemplateService(scriptService);
|
||||
for (Map.Entry<String, ProcessorFactoryProvider> entry : processorFactoryProviders.entrySet()) {
|
||||
Processor.Factory processorFactory = entry.getValue().get(environment, templateService);
|
||||
Processor.Factory processorFactory = entry.getValue().apply(environment, templateService);
|
||||
processorFactories.put(entry.getKey(), processorFactory);
|
||||
}
|
||||
this.processorFactoryRegistry = Collections.unmodifiableMap(processorFactories);
|
||||
|
|
Loading…
Reference in New Issue