4343import io .vertx .core .Future ;
4444import io .vertx .core .Handler ;
4545import io .vertx .core .Promise ;
46+ import io .vertx .core .WorkerExecutor ;
4647import io .vertx .core .buffer .Buffer ;
4748import io .vertx .core .http .HttpServerOptions ;
4849import io .vertx .core .http .HttpServerResponse ;
@@ -133,14 +134,16 @@ public class UIDOperatorVerticle extends AbstractVerticle {
133134 public static final long OPT_OUT_CHECK_CUTOFF_DATE = Instant .parse ("2023-09-01T00:00:00.00Z" ).getEpochSecond ();
134135 private final Handler <Boolean > saltRetrievalResponseHandler ;
135136 private final int allowClockSkewSeconds ;
136- private final ComputePoolService computePoolService ;
137+ private final WorkerExecutor computeWorkerPool ;
137138 protected Map <Integer , Set <String >> siteIdToInvalidOriginsAndAppNames = new HashMap <>();
138139 protected boolean keySharingEndpointProvideAppNames ;
139140 protected Instant lastInvalidOriginProcessTime = Instant .now ();
140141
141142 private final int optOutStatusMaxRequestSize ;
142143 private final boolean optOutStatusApiEnabled ;
143144
145+ private final boolean isAsyncBatchRequestsEnabled ;
146+
144147 //"Android" is from https://github.com/IABTechLab/uid2-android-sdk/blob/ff93ebf597f5de7d440a84f7015a334ba4138ede/sdk/src/main/java/com/uid2/UID2Client.kt#L46
145148 //"ios"/"tvos" is from https://github.com/IABTechLab/uid2-ios-sdk/blob/91c290d29a7093cfc209eca493d1fee80c17e16a/Sources/UID2/UID2Client.swift#L36-L38
146149 private static final List <String > SUPPORTED_IN_APP = Arrays .asList ("Android" , "ios" , "tvos" );
@@ -166,7 +169,7 @@ public UIDOperatorVerticle(IConfigStore configStore,
166169 SecureLinkValidatorService secureLinkValidatorService ,
167170 Handler <Boolean > saltRetrievalResponseHandler ,
168171 UidInstanceIdProvider uidInstanceIdProvider ,
169- ComputePoolService computePoolService ) {
172+ WorkerExecutor computeWorkerPool ) {
170173 this .keyManager = keyManager ;
171174 this .secureLinkValidatorService = secureLinkValidatorService ;
172175 try {
@@ -200,7 +203,8 @@ public UIDOperatorVerticle(IConfigStore configStore,
200203 this .identityV3Enabled = config .getBoolean (IdentityV3Prop , false );
201204 this .disableOptoutToken = config .getBoolean (DisableOptoutTokenProp , false );
202205 this .uidInstanceIdProvider = uidInstanceIdProvider ;
203- this .computePoolService = computePoolService ;
206+ this .computeWorkerPool = computeWorkerPool ;
207+ this .isAsyncBatchRequestsEnabled = config .getBoolean (EnableAsyncBatchRequestProp , false );
204208 }
205209
206210 @ Override
@@ -285,10 +289,6 @@ private void setUpEncryptedRoutes(Router mainRouter, BodyHandler bodyHandler) {
285289 rc -> encryptedPayloadHandler .handleTokenRefresh (rc , this ::handleTokenRefreshV2 )));
286290 mainRouter .post (V2_TOKEN_VALIDATE .toString ()).handler (bodyHandler ).handler (auth .handleV1 (
287291 rc -> encryptedPayloadHandler .handle (rc , this ::handleTokenValidateV2 ), Role .GENERATOR ));
288- mainRouter .post (V2_IDENTITY_BUCKETS .toString ()).handler (bodyHandler ).handler (auth .handleV1 (
289- rc -> encryptedPayloadHandler .handleAsync (rc , this ::handleBucketsV2Async ), Role .MAPPER ));
290- mainRouter .post (V2_IDENTITY_MAP .toString ()).handler (bodyHandler ).handler (auth .handleV1 (
291- rc -> encryptedPayloadHandler .handleAsync (rc , this ::handleIdentityMapV2Async ), Role .MAPPER ));
292292 mainRouter .post (V2_KEY_LATEST .toString ()).handler (bodyHandler ).handler (auth .handleV1 (
293293 rc -> encryptedPayloadHandler .handle (rc , this ::handleKeysRequestV2 ), Role .ID_READER ));
294294 mainRouter .post (V2_KEY_SHARING .toString ()).handler (bodyHandler ).handler (auth .handleV1 (
@@ -306,8 +306,21 @@ private void setUpEncryptedRoutes(Router mainRouter, BodyHandler bodyHandler) {
306306 if (this .clientSideTokenGenerate )
307307 mainRouter .post (V2_TOKEN_CLIENTGENERATE .toString ()).handler (bodyHandler ).handler (this ::handleClientSideTokenGenerate );
308308
309- mainRouter .post (V3_IDENTITY_MAP .toString ()).handler (bodyHandler ).handler (auth .handleV1 (
310- rc -> encryptedPayloadHandler .handleAsync (rc , this ::handleIdentityMapV3Async ), Role .MAPPER ));
309+ if (isAsyncBatchRequestsEnabled ) {
310+ mainRouter .post (V2_IDENTITY_BUCKETS .toString ()).handler (bodyHandler ).handler (auth .handleV1 (
311+ rc -> encryptedPayloadHandler .handleAsync (rc , this ::handleBucketsV2Async ), Role .MAPPER ));
312+ mainRouter .post (V2_IDENTITY_MAP .toString ()).handler (bodyHandler ).handler (auth .handleV1 (
313+ rc -> encryptedPayloadHandler .handleAsync (rc , this ::handleIdentityMapV2Async ), Role .MAPPER ));
314+ mainRouter .post (V3_IDENTITY_MAP .toString ()).handler (bodyHandler ).handler (auth .handleV1 (
315+ rc -> encryptedPayloadHandler .handleAsync (rc , this ::handleIdentityMapV3Async ), Role .MAPPER ));
316+ } else {
317+ mainRouter .post (V2_IDENTITY_BUCKETS .toString ()).handler (bodyHandler ).handler (auth .handleV1 (
318+ rc -> encryptedPayloadHandler .handle (rc , this ::handleBucketsV2 ), Role .MAPPER ));
319+ mainRouter .post (V2_IDENTITY_MAP .toString ()).handler (bodyHandler ).handler (auth .handleV1 (
320+ rc -> encryptedPayloadHandler .handle (rc , this ::handleIdentityMapV2 ), Role .MAPPER ));
321+ mainRouter .post (V3_IDENTITY_MAP .toString ()).handler (bodyHandler ).handler (auth .handleV1 (
322+ rc -> encryptedPayloadHandler .handle (rc , this ::handleIdentityMapV3 ), Role .MAPPER ));
323+ }
311324 }
312325
313326 private void handleClientSideTokenGenerate (RoutingContext rc ) {
@@ -1041,8 +1054,9 @@ private Future handleLogoutAsyncV2(RoutingContext rc) {
10411054 }
10421055
10431056 private Future <Void > handleBucketsV2Async (RoutingContext rc ) {
1044- return computePoolService .executeBlocking (() -> {
1057+ return computeWorkerPool .executeBlocking (() -> {
10451058 handleBucketsV2 (rc );
1059+ return null ;
10461060 });
10471061 }
10481062
@@ -1232,8 +1246,9 @@ private boolean validateServiceLink(RoutingContext rc) {
12321246 }
12331247
12341248 private Future <Void > handleIdentityMapV2Async (RoutingContext rc ) {
1235- return computePoolService .executeBlocking (() -> {
1249+ return computeWorkerPool .executeBlocking (() -> {
12361250 handleIdentityMapV2 (rc );
1251+ return null ;
12371252 });
12381253 }
12391254
@@ -1301,8 +1316,9 @@ private InputUtil.InputVal[] getIdentityMapV2Input(RoutingContext rc) {
13011316 }
13021317
13031318 private Future <Void > handleIdentityMapV3Async (RoutingContext rc ) {
1304- return computePoolService .executeBlocking (() -> {
1319+ return computeWorkerPool .executeBlocking (() -> {
13051320 handleIdentityMapV3 (rc );
1321+ return null ;
13061322 });
13071323 }
13081324
0 commit comments