Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate PBS from using embedded Vert.x to verticles #2306

Merged
merged 17 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import org.prebid.server.json.JacksonMapper;
import org.prebid.server.util.HttpUtil;
import org.prebid.server.vertx.Initializable;
import org.prebid.server.vertx.http.HttpClient;
import org.prebid.server.vertx.http.model.HttpClientResponse;
import org.prebid.server.vertx.httpclient.HttpClient;
import org.prebid.server.vertx.httpclient.model.HttpClientResponse;

import java.util.Arrays;
import java.util.Collections;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import org.prebid.server.exception.PreBidException;
import org.prebid.server.json.JacksonMapper;
import org.prebid.server.util.HttpUtil;
import org.prebid.server.vertx.http.HttpClient;
import org.prebid.server.vertx.http.model.HttpClientResponse;
import org.prebid.server.vertx.httpclient.HttpClient;
import org.prebid.server.vertx.httpclient.model.HttpClientResponse;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,6 @@ public Future<BidRequest> enrichBidRequestWithGeolocationData(AuctionContext auc
.build();

return Future.succeededFuture(bidRequest.toBuilder().device(updatedDevice).build());

}

public Future<BidRequest> enrichBidRequestWithAccountAndPrivacyData(AuctionContext auctionContext) {
Expand All @@ -259,7 +258,6 @@ public Future<BidRequest> enrichBidRequestWithAccountAndPrivacyData(AuctionConte
.device(ObjectUtils.defaultIfNull(enrichedDevice, device))
.regs(ObjectUtils.defaultIfNull(enrichedRegs, regs))
.build());

}

private static Regs enrichRegs(Regs regs, PrivacyContext privacyContext, Account account) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
import org.prebid.server.bidder.model.HttpRequest;
import org.prebid.server.log.ConditionalLogger;
import org.prebid.server.metric.Metrics;
import org.prebid.server.vertx.http.HttpClient;
import org.prebid.server.vertx.http.model.HttpClientResponse;
import org.prebid.server.vertx.httpclient.HttpClient;
import org.prebid.server.vertx.httpclient.model.HttpClientResponse;

import java.util.Objects;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import org.prebid.server.proto.openrtb.ext.response.ExtHttpCall;
import org.prebid.server.proto.openrtb.ext.response.FledgeAuctionConfig;
import org.prebid.server.util.HttpUtil;
import org.prebid.server.vertx.http.HttpClient;
import org.prebid.server.vertx.http.model.HttpClientResponse;
import org.prebid.server.vertx.httpclient.HttpClient;
import org.prebid.server.vertx.httpclient.model.HttpClientResponse;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/prebid/server/cache/CacheService.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@
import org.prebid.server.util.HttpUtil;
import org.prebid.server.util.ObjectUtil;
import org.prebid.server.vast.VastModifier;
import org.prebid.server.vertx.http.HttpClient;
import org.prebid.server.vertx.http.model.HttpClientResponse;
import org.prebid.server.vertx.httpclient.HttpClient;
import org.prebid.server.vertx.httpclient.model.HttpClientResponse;

import java.net.MalformedURLException;
import java.net.URL;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import org.prebid.server.spring.config.model.ExternalConversionProperties;
import org.prebid.server.util.HttpUtil;
import org.prebid.server.vertx.Initializable;
import org.prebid.server.vertx.http.HttpClient;
import org.prebid.server.vertx.http.model.HttpClientResponse;
import org.prebid.server.vertx.httpclient.HttpClient;
import org.prebid.server.vertx.httpclient.model.HttpClientResponse;

import java.io.IOException;
import java.math.BigDecimal;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/prebid/server/floors/PriceFloorFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
import org.prebid.server.settings.model.AccountPriceFloorsFetchConfig;
import org.prebid.server.util.HttpUtil;
import org.prebid.server.util.ObjectUtil;
import org.prebid.server.vertx.http.HttpClient;
import org.prebid.server.vertx.http.model.HttpClientResponse;
import org.prebid.server.vertx.httpclient.HttpClient;
import org.prebid.server.vertx.httpclient.model.HttpClientResponse;

import java.util.Map;
import java.util.Objects;
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/org/prebid/server/handler/BidderParamHandler.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,30 @@
package org.prebid.server.handler;

import io.vertx.core.Handler;
import io.vertx.core.http.HttpMethod;
import io.vertx.ext.web.RoutingContext;
import org.prebid.server.model.Endpoint;
import org.prebid.server.util.HttpUtil;
import org.prebid.server.validation.BidderParamValidator;
import org.prebid.server.vertx.verticles.server.HttpEndpoint;
import org.prebid.server.vertx.verticles.server.application.ApplicationResource;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

public class BidderParamHandler implements Handler<RoutingContext> {
public class BidderParamHandler implements ApplicationResource {

private final BidderParamValidator bidderParamValidator;

public BidderParamHandler(BidderParamValidator bidderParamValidator) {
this.bidderParamValidator = Objects.requireNonNull(bidderParamValidator);
}

@Override
public List<HttpEndpoint> endpoints() {
return Collections.singletonList(HttpEndpoint.of(HttpMethod.GET, Endpoint.bidder_params.value()));
}

@Override
public void handle(RoutingContext routingContext) {
HttpUtil.executeSafely(routingContext, Endpoint.bidder_params,
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/org/prebid/server/handler/CookieSyncHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import io.netty.handler.codec.http.HttpHeaderValues;
import io.netty.handler.codec.http.HttpResponseStatus;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.ext.web.RoutingContext;
Expand Down Expand Up @@ -40,12 +40,16 @@
import org.prebid.server.settings.ApplicationSettings;
import org.prebid.server.settings.model.Account;
import org.prebid.server.util.HttpUtil;
import org.prebid.server.vertx.verticles.server.HttpEndpoint;
import org.prebid.server.vertx.verticles.server.application.ApplicationResource;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;

public class CookieSyncHandler implements Handler<RoutingContext> {
public class CookieSyncHandler implements ApplicationResource {

private static final Logger logger = LoggerFactory.getLogger(CookieSyncHandler.class);
private static final ConditionalLogger BAD_REQUEST_LOGGER = new ConditionalLogger(logger);
Expand Down Expand Up @@ -93,6 +97,11 @@ public CookieSyncHandler(long defaultTimeout,
this.mapper = Objects.requireNonNull(mapper);
}

@Override
public List<HttpEndpoint> endpoints() {
return Collections.singletonList(HttpEndpoint.of(HttpMethod.POST, Endpoint.cookie_sync.value()));
}

@Override
public void handle(RoutingContext routingContext) {
metrics.updateCookieSyncRequestMetric();
Expand Down

This file was deleted.

13 changes: 11 additions & 2 deletions src/main/java/org/prebid/server/handler/GetuidsHandler.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.prebid.server.handler;

import com.fasterxml.jackson.annotation.JsonInclude;
import io.vertx.core.Handler;
import io.vertx.core.http.HttpMethod;
import io.vertx.ext.web.RoutingContext;
import lombok.AllArgsConstructor;
import lombok.Value;
Expand All @@ -10,12 +10,16 @@
import org.prebid.server.json.JacksonMapper;
import org.prebid.server.model.Endpoint;
import org.prebid.server.util.HttpUtil;
import org.prebid.server.vertx.verticles.server.HttpEndpoint;
import org.prebid.server.vertx.verticles.server.application.ApplicationResource;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;

public class GetuidsHandler implements Handler<RoutingContext> {
public class GetuidsHandler implements ApplicationResource {

private final UidsCookieService uidsCookieService;
private final JacksonMapper mapper;
Expand All @@ -25,6 +29,11 @@ public GetuidsHandler(UidsCookieService uidsCookieService, JacksonMapper mapper)
this.mapper = Objects.requireNonNull(mapper);
}

@Override
public List<HttpEndpoint> endpoints() {
return Collections.singletonList(HttpEndpoint.of(HttpMethod.GET, Endpoint.getuids.value()));
}

@Override
public void handle(RoutingContext routingContext) {
final Map<String, String> uids = uidsFrom(routingContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import io.netty.handler.codec.http.HttpResponseStatus;
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Handler;
import io.vertx.core.buffer.Buffer;
import io.vertx.core.http.HttpHeaders;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.http.HttpServerResponse;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
Expand All @@ -29,15 +29,19 @@
import org.prebid.server.settings.model.AccountEventsConfig;
import org.prebid.server.util.HttpUtil;
import org.prebid.server.util.ResourceUtil;
import org.prebid.server.vertx.verticles.server.HttpEndpoint;
import org.prebid.server.vertx.verticles.server.application.ApplicationResource;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
* Accepts notifications from browsers and mobile application for further processing by {@link AnalyticsReporter}
* and responding with tracking pixel when requested.
*/
public class NotificationEventHandler implements Handler<RoutingContext> {
public class NotificationEventHandler implements ApplicationResource {

private static final Logger logger = LoggerFactory.getLogger(NotificationEventHandler.class);

Expand Down Expand Up @@ -77,6 +81,11 @@ private static TrackingPixel createTrackingPixel() {
return TrackingPixel.of(PNG_CONTENT_TYPE, bytes);
}

@Override
public List<HttpEndpoint> endpoints() {
return Collections.singletonList(HttpEndpoint.of(HttpMethod.GET, Endpoint.event.value()));
}

@Override
public void handle(RoutingContext routingContext) {
try {
Expand Down
14 changes: 12 additions & 2 deletions src/main/java/org/prebid/server/handler/OptoutHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import io.netty.handler.codec.http.HttpResponseStatus;
import io.vertx.core.AsyncResult;
import io.vertx.core.Handler;
import io.vertx.core.http.Cookie;
import io.vertx.core.http.HttpMethod;
import io.vertx.core.logging.Logger;
import io.vertx.core.logging.LoggerFactory;
import io.vertx.ext.web.RoutingContext;
Expand All @@ -14,12 +14,15 @@
import org.prebid.server.optout.GoogleRecaptchaVerifier;
import org.prebid.server.optout.model.RecaptchaResponse;
import org.prebid.server.util.HttpUtil;
import org.prebid.server.vertx.verticles.server.HttpEndpoint;
import org.prebid.server.vertx.verticles.server.application.ApplicationResource;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Objects;

public class OptoutHandler implements Handler<RoutingContext> {
public class OptoutHandler implements ApplicationResource {

private static final Logger logger = LoggerFactory.getLogger(OptoutHandler.class);

Expand All @@ -41,6 +44,13 @@ public OptoutHandler(GoogleRecaptchaVerifier googleRecaptchaVerifier, UidsCookie
this.optinUrl = Objects.requireNonNull(optinUrl);
}

@Override
public List<HttpEndpoint> endpoints() {
return List.of(
HttpEndpoint.of(HttpMethod.GET, Endpoint.optout.value()),
HttpEndpoint.of(HttpMethod.POST, Endpoint.optout.value()));
}

@Override
public void handle(RoutingContext routingContext) {
final String recaptcha = getRequestParam(routingContext, RECAPTCHA_PARAM);
Expand Down
Loading
Loading