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

Module Execution: Add Property to Require Account Config #3525

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 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 @@ -18,9 +18,9 @@
import org.prebid.server.hooks.modules.com.confiant.adquality.core.BidsScanResult;
import org.prebid.server.hooks.modules.com.confiant.adquality.core.BidsScanner;
import org.prebid.server.hooks.modules.com.confiant.adquality.model.GroupByIssues;
import org.prebid.server.hooks.modules.com.confiant.adquality.v1.model.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationAction;
import org.prebid.server.hooks.v1.InvocationResult;
import org.prebid.server.hooks.v1.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationStatus;
import org.prebid.server.hooks.v1.auction.AuctionInvocationContext;
import org.prebid.server.hooks.v1.bidder.AllProcessedBidResponsesHook;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import org.prebid.server.hooks.modules.fiftyone.devicedetection.model.boundary.CollectedEvidence;
import org.prebid.server.hooks.modules.fiftyone.devicedetection.v1.model.ModuleContext;
import org.prebid.server.hooks.modules.fiftyone.devicedetection.v1.model.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationAction;
import org.prebid.server.hooks.v1.InvocationContext;
import org.prebid.server.hooks.v1.InvocationResult;
import org.prebid.server.hooks.v1.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationStatus;
import org.prebid.server.hooks.v1.entrypoint.EntrypointHook;
import org.prebid.server.hooks.v1.entrypoint.EntrypointPayload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
import org.prebid.server.hooks.modules.fiftyone.devicedetection.v1.core.EnrichmentResult;
import org.prebid.server.hooks.modules.fiftyone.devicedetection.v1.core.SecureHeadersRetriever;
import org.prebid.server.hooks.modules.fiftyone.devicedetection.v1.model.ModuleContext;
import org.prebid.server.hooks.modules.fiftyone.devicedetection.v1.model.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationAction;
import org.prebid.server.hooks.v1.InvocationResult;
import org.prebid.server.hooks.v1.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationStatus;
import org.prebid.server.hooks.v1.auction.AuctionInvocationContext;
import org.prebid.server.hooks.v1.auction.AuctionRequestPayload;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import org.prebid.server.hooks.modules.ortb2.blocking.core.model.ExecutionResult;
import org.prebid.server.hooks.modules.ortb2.blocking.model.ModuleContext;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.BidderRequestPayloadImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationAction;
import org.prebid.server.hooks.v1.InvocationResult;
import org.prebid.server.hooks.v1.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationStatus;
import org.prebid.server.hooks.v1.bidder.BidderInvocationContext;
import org.prebid.server.hooks.v1.bidder.BidderRequestHook;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
import org.prebid.server.hooks.modules.ortb2.blocking.core.model.ExecutionResult;
import org.prebid.server.hooks.modules.ortb2.blocking.model.ModuleContext;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.BidderResponsePayloadImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.InvocationResultImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.analytics.ActivityImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.analytics.AppliedToImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.analytics.ResultImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.analytics.TagsImpl;
import org.prebid.server.hooks.v1.InvocationAction;
import org.prebid.server.hooks.v1.InvocationResult;
import org.prebid.server.hooks.v1.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationStatus;
import org.prebid.server.hooks.v1.analytics.Result;
import org.prebid.server.hooks.v1.analytics.Tags;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import org.prebid.server.hooks.modules.ortb2.blocking.model.ModuleContext;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.BidderInvocationContextImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.BidderRequestPayloadImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationAction;
import org.prebid.server.hooks.v1.InvocationResult;
import org.prebid.server.hooks.v1.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationStatus;
import org.prebid.server.hooks.v1.PayloadUpdate;
import org.prebid.server.hooks.v1.bidder.BidderRequestPayload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
import org.prebid.server.hooks.modules.ortb2.blocking.model.ModuleContext;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.BidderInvocationContextImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.BidderResponsePayloadImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.InvocationResultImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.analytics.ActivityImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.analytics.AppliedToImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.analytics.ResultImpl;
import org.prebid.server.hooks.modules.ortb2.blocking.v1.model.analytics.TagsImpl;
import org.prebid.server.hooks.v1.InvocationAction;
import org.prebid.server.hooks.v1.InvocationResult;
import org.prebid.server.hooks.v1.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationStatus;
import org.prebid.server.hooks.v1.PayloadUpdate;
import org.prebid.server.hooks.v1.bidder.BidderResponsePayload;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
import org.prebid.server.hooks.modules.pb.response.correction.core.ResponseCorrectionProvider;
import org.prebid.server.hooks.modules.pb.response.correction.core.config.model.Config;
import org.prebid.server.hooks.modules.pb.response.correction.core.correction.Correction;
import org.prebid.server.hooks.modules.pb.response.correction.v1.model.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationAction;
import org.prebid.server.hooks.v1.InvocationResult;
import org.prebid.server.hooks.v1.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationStatus;
import org.prebid.server.hooks.v1.auction.AuctionInvocationContext;
import org.prebid.server.hooks.v1.bidder.AllProcessedBidResponsesHook;
Expand Down Expand Up @@ -57,7 +57,7 @@ public Future<InvocationResult<AllProcessedBidResponsesPayload>> call(AllProcess
return noAction();
}

final InvocationResult<AllProcessedBidResponsesPayload> invocationResult = InvocationResultImpl.builder()
final InvocationResult<AllProcessedBidResponsesPayload> invocationResult = InvocationResultImpl.<AllProcessedBidResponsesPayload>builder()
.status(InvocationStatus.success)
.action(InvocationAction.update)
.payloadUpdate(initialPayload -> AllProcessedBidResponsesPayloadImpl.of(
Expand All @@ -84,15 +84,15 @@ private static List<BidderResponse> applyCorrections(List<BidderResponse> bidder
}

private Future<InvocationResult<AllProcessedBidResponsesPayload>> failure(String message) {
return Future.succeededFuture(InvocationResultImpl.builder()
return Future.succeededFuture(InvocationResultImpl.<AllProcessedBidResponsesPayload>builder()
.status(InvocationStatus.failure)
.message(message)
.action(InvocationAction.no_action)
.build());
}

private static Future<InvocationResult<AllProcessedBidResponsesPayload>> noAction() {
return Future.succeededFuture(InvocationResultImpl.builder()
return Future.succeededFuture(InvocationResultImpl.<AllProcessedBidResponsesPayload>builder()
.status(InvocationStatus.success)
.action(InvocationAction.no_action)
.build());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
import org.prebid.server.hooks.modules.pb.richmedia.filter.model.AnalyticsResult;
import org.prebid.server.hooks.modules.pb.richmedia.filter.model.MraidFilterResult;
import org.prebid.server.hooks.modules.pb.richmedia.filter.model.PbRichMediaFilterProperties;
import org.prebid.server.hooks.modules.pb.richmedia.filter.v1.model.InvocationResultImpl;
import org.prebid.server.hooks.modules.pb.richmedia.filter.v1.model.analytics.ActivityImpl;
import org.prebid.server.hooks.modules.pb.richmedia.filter.v1.model.analytics.AppliedToImpl;
import org.prebid.server.hooks.modules.pb.richmedia.filter.v1.model.analytics.ResultImpl;
import org.prebid.server.hooks.modules.pb.richmedia.filter.v1.model.analytics.TagsImpl;
import org.prebid.server.hooks.v1.InvocationAction;
import org.prebid.server.hooks.v1.InvocationResult;
import org.prebid.server.hooks.v1.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationStatus;
import org.prebid.server.hooks.v1.analytics.Result;
import org.prebid.server.hooks.v1.analytics.Tags;
Expand Down
32 changes: 24 additions & 8 deletions src/main/java/org/prebid/server/hooks/execution/GroupExecutor.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.prebid.server.hooks.execution;

import com.fasterxml.jackson.databind.node.ObjectNode;
import io.vertx.core.AsyncResult;
import io.vertx.core.Future;
import io.vertx.core.Promise;
Expand All @@ -8,8 +9,12 @@
import org.prebid.server.hooks.execution.model.HookExecutionContext;
import org.prebid.server.hooks.execution.model.HookId;
import org.prebid.server.hooks.v1.Hook;
import org.prebid.server.hooks.v1.InvocationAction;
import org.prebid.server.hooks.v1.InvocationContext;
import org.prebid.server.hooks.v1.InvocationResult;
import org.prebid.server.hooks.v1.InvocationResultImpl;
import org.prebid.server.hooks.v1.InvocationStatus;
import org.prebid.server.hooks.v1.auction.AuctionInvocationContext;
import org.prebid.server.log.ConditionalLogger;
import org.prebid.server.log.LoggerFactory;

Expand All @@ -25,6 +30,7 @@ class GroupExecutor<PAYLOAD, CONTEXT extends InvocationContext> {

private final Vertx vertx;
private final Clock clock;
private final boolean isConfigToInvokeRequired;

private ExecutionGroup group;
private PAYLOAD initialPayload;
Expand All @@ -33,16 +39,18 @@ class GroupExecutor<PAYLOAD, CONTEXT extends InvocationContext> {
private HookExecutionContext hookExecutionContext;
private boolean rejectAllowed;

private GroupExecutor(Vertx vertx, Clock clock) {
private GroupExecutor(Vertx vertx, Clock clock, boolean isConfigToInvokeRequired) {
this.vertx = vertx;
this.clock = clock;
this.isConfigToInvokeRequired = isConfigToInvokeRequired;
}

public static <PAYLOAD, CONTEXT extends InvocationContext> GroupExecutor<PAYLOAD, CONTEXT> create(
Vertx vertx,
Clock clock) {
Clock clock,
boolean isConfigToInvokeRequired) {

return new GroupExecutor<>(vertx, clock);
return new GroupExecutor<>(vertx, clock, isConfigToInvokeRequired);
}

public GroupExecutor<PAYLOAD, CONTEXT> withGroup(ExecutionGroup group) {
Expand Down Expand Up @@ -107,11 +115,19 @@ private Future<InvocationResult<PAYLOAD>> executeHook(
return Future.failedFuture(new FailedException("Hook implementation does not exist or disabled"));
}

return executeWithTimeout(
() -> hook.call(
groupResult.payload(),
invocationContextProvider.apply(timeout, hookId, moduleContextFor(hookId))),
timeout);
final CONTEXT invocationContext = invocationContextProvider.apply(timeout, hookId, moduleContextFor(hookId));

if (isConfigToInvokeRequired && invocationContext instanceof AuctionInvocationContext) {
final ObjectNode accountConfig = ((AuctionInvocationContext) invocationContext).accountConfig();
if (accountConfig == null || accountConfig.isNull()) {
return Future.succeededFuture(InvocationResultImpl.<PAYLOAD>builder()
.status(InvocationStatus.success)
.action(InvocationAction.no_invocation)
.build());
}
}

return executeWithTimeout(() -> hook.call(groupResult.payload(), invocationContext), timeout);
}

private <T> Future<T> executeWithTimeout(Supplier<Future<T>> action, Long timeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ private static ExecutionAction toExecutionAction(InvocationAction action) {
case reject -> ExecutionAction.reject;
case update -> ExecutionAction.update;
case no_action -> ExecutionAction.no_action;
case no_invocation -> ExecutionAction.no_invocation;
};
}

Expand Down
Loading
Loading