Skip to content

Commit

Permalink
HB-17610: Replace NAC library with internal one (#1201)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleksandr Zhevedenko authored and GitHub Enterprise committed Aug 8, 2023
1 parent 74df36e commit 7c4186f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
12 changes: 8 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<metrics-prometheus.version>0.12.0</metrics-prometheus.version>
<maxmind-client.version>2.12.0</maxmind-client.version>
<commons-validator.version>1.6</commons-validator.version>
<netacuity.version>6.0.1.0</netacuity.version>
<ip-geo-client.version>0.0.2</ip-geo-client.version>
<deviceatlas-common.version>1.1.1</deviceatlas-common.version>
<deviceatlas-deviceapi.version>2.1.2</deviceatlas-deviceapi.version>
<fiftyonedegrees.version>3.2.18.1</fiftyonedegrees.version>
Expand Down Expand Up @@ -113,6 +113,10 @@
<name>Rubicon Nexus DeviceAtlas</name>
<url>https://maven.fanops.net/nexus/repository/device-atlas</url>
</repository>
<repository>
<id>revv-components-release</id>
<url>https://mvn.fanops.net/nexus/content/repositories/revv-components-release</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
Expand Down Expand Up @@ -376,9 +380,9 @@
<version>${metrics-prometheus.version}</version>
</dependency>
<dependency>
<groupId>sources</groupId>
<artifactId>netacuity-api</artifactId>
<version>${netacuity.version}</version>
<groupId>com.magnite</groupId>
<artifactId>ip-geo-client</artifactId>
<version>${ip-geo-client.version}</version>
</dependency>
<dependency>
<groupId>com.maxmind.geoip2</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
import io.vertx.core.Vertx;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import net.digitalenvoy.netacuity.api.DbAccessor;
import net.digitalenvoy.netacuity.api.DbAccessorFactory;
import net.digitalenvoy.netacuity.api.PulseQuery;
import com.magnite.ipgeoclient.accessor.DbAccessor;
import com.magnite.ipgeoclient.accessor.DbAccessorFactory;
import com.magnite.ipgeoclient.query.ConnectionQuery;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.WordUtils;
import org.prebid.server.exception.PreBidException;
Expand Down Expand Up @@ -93,7 +93,7 @@ private void doLookup(Promise<GeoInfo> promise, InetAddress serverAddress, Strin
final DbAccessor dbAccessor = DbAccessorFactory.getAccessor(serverAddress, API_ID,
Math.toIntExact(remainingTimeout));

final PulseQuery query = dbAccessor.query(PulseQuery.class, lookupAddress);
final ConnectionQuery query = dbAccessor.query(ConnectionQuery.class, lookupAddress);
if (isValidResponse(query)) {
successWith(query, startTime).setHandler(promise);
} else {
Expand All @@ -108,12 +108,12 @@ private void doLookup(Promise<GeoInfo> promise, InetAddress serverAddress, Strin
* In case NAC cannot determine geo info by IP it responds with strange result where country = ** or similar.
* So, this method guarantees result is valid.
*/
private static boolean isValidResponse(PulseQuery query) {
private static boolean isValidResponse(ConnectionQuery query) {
final String country = query.getTwoLetterCountry();
return StringUtils.length(country) == 2 && StringUtils.isAlpha(country);
}

private Future<GeoInfo> successWith(PulseQuery query, long startTime) {
private Future<GeoInfo> successWith(ConnectionQuery query, long startTime) {
metrics.updateRequestTimeMetric(MetricName.geolocation_request_time, responseTime(startTime));

return Future.succeededFuture(GeoInfo.builder()
Expand All @@ -131,7 +131,7 @@ private Future<GeoInfo> successWith(PulseQuery query, long startTime) {
.build());
}

private static ZoneId getTimeZone(PulseQuery query) {
private static ZoneId getTimeZone(ConnectionQuery query) {
final String originalTimeZone = query.getTimezoneName();
final String capitalizedTimeZone = WordUtils.capitalizeFully(originalTimeZone, '/', '_');
try {
Expand Down

0 comments on commit 7c4186f

Please sign in to comment.