Skip to content

Commit 99948ba

Browse files
committed
add static GeoIpProcessorBridge#newFactory(IpDatabaseProviderBridge)
1 parent caf01a5 commit 99948ba

File tree

5 files changed

+23
-41
lines changed

5 files changed

+23
-41
lines changed

libs/logstash-bridge/src/main/java/org/elasticsearch/logstashbridge/geoip/GeoIpProcessorBridge.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,25 @@
99
package org.elasticsearch.logstashbridge.geoip;
1010

1111
import org.elasticsearch.ingest.geoip.GeoIpProcessor;
12+
import org.elasticsearch.logstashbridge.StableBridgeAPI;
1213
import org.elasticsearch.logstashbridge.ingest.ProcessorBridge;
1314

1415
/**
1516
* An external bridge for {@link GeoIpProcessor}
1617
*/
17-
public interface GeoIpProcessorBridge {
18+
public interface GeoIpProcessorBridge extends StableBridgeAPI<GeoIpProcessor> {
1819

20+
static Factory newFactory(final IpDatabaseProviderBridge ipDatabaseProviderBridge) {
21+
return new Factory(ipDatabaseProviderBridge);
22+
}
23+
24+
/**
25+
* A {@link ProcessorBridge.Factory} implementation for the {@link GeoIpProcessor}
26+
*/
1927
class Factory extends ProcessorBridge.Factory.ProxyInternal {
20-
public Factory(final String type, final IpDatabaseProviderBridge ipDatabaseProviderBridge) {
21-
super(new GeoIpProcessor.Factory(type, ipDatabaseProviderBridge.toInternal()));
28+
29+
Factory(final IpDatabaseProviderBridge ipDatabaseProviderBridge) {
30+
super(new GeoIpProcessor.Factory("geoip", ipDatabaseProviderBridge.toInternal()));
2231
}
2332
}
2433
}

libs/logstash-bridge/src/main/java/org/elasticsearch/logstashbridge/geoip/IpDatabaseBridge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public interface IpDatabaseBridge extends StableBridgeAPI<IpDatabase> {
3434
* The {@code IpDatabaseBridge.AbstractExternal} is an abstract base class for implementing
3535
* the {@link IpDatabaseBridge} externally to the Elasticsearch code-base. It takes care of
3636
* the details of maintaining a singular internal-form implementation of {@link IpDatabase}
37-
* that proxies calls through the external implementation.
37+
* that proxies calls to the external implementation.
3838
*/
3939
abstract class AbstractExternal implements IpDatabaseBridge {
4040
private ProxyExternal internalDatabase;

libs/logstash-bridge/src/main/java/org/elasticsearch/logstashbridge/geoip/IpDatabaseProviderBridge.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public interface IpDatabaseProviderBridge extends StableBridgeAPI<IpDatabaseProv
2929
* The {@code IpDatabaseProviderBridge.AbstractExternal} is an abstract base class for implementing
3030
* the {@link IpDatabaseProviderBridge} externally to the Elasticsearch code-base. It takes care of
3131
* the details of maintaining a singular internal-form implementation of {@link IpDatabaseProvider}
32-
* that proxies calls through the external implementation.
32+
* that proxies calls to the external implementation.
3333
*/
3434
abstract class AbstractExternal implements IpDatabaseProviderBridge {
3535
private AbstractExternal.ProxyExternal internalProcessor;

libs/logstash-bridge/src/main/java/org/elasticsearch/logstashbridge/ingest/FailProcessorExceptionBridge.java

Lines changed: 0 additions & 23 deletions
This file was deleted.

libs/logstash-bridge/src/main/java/org/elasticsearch/logstashbridge/ingest/ProcessorBridge.java

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,6 @@ static Factory fromInternal(final Processor.Factory delegate) {
189189
return new ProxyInternal(delegate);
190190
}
191191

192-
@Override
193-
default Processor.Factory toInternal() {
194-
final Factory stableAPIFactory = this;
195-
return (registry, tag, description, config, projectId) -> stableAPIFactory.create(
196-
StableBridgeAPI.fromInternal(registry, Factory::fromInternal),
197-
tag,
198-
description,
199-
config
200-
).toInternal();
201-
}
202-
203192
/**
204193
* An implementation of {@link ProcessorBridge.Factory} that proxies to an internal {@link Processor.Factory}
205194
*/
@@ -216,9 +205,16 @@ public ProcessorBridge create(
216205
final String description,
217206
final Map<String, Object> config
218207
) throws Exception {
219-
return ProcessorBridge.fromInternal(
220-
this.internalDelegate.create(StableBridgeAPI.toInternal(registry), processorTag, description, config, ProjectId.DEFAULT)
208+
final Map<String, Processor.Factory> internalRegistry = StableBridgeAPI.toInternal(registry);
209+
final Processor.Factory internalFactory = toInternal();
210+
final Processor internalProcessor = internalFactory.create(
211+
internalRegistry,
212+
processorTag,
213+
description,
214+
config,
215+
ProjectId.DEFAULT
221216
);
217+
return ProcessorBridge.fromInternal(internalProcessor);
222218
}
223219

224220
@Override

0 commit comments

Comments
 (0)