|
1 | 1 | package com.uid2.optout; |
2 | 2 |
|
3 | 3 | import com.uid2.optout.vertx.*; |
| 4 | +import com.uid2.optout.traffic.TrafficFilter.MalformedTrafficFilterConfigException; |
| 5 | +import com.uid2.optout.traffic.TrafficCalculator.MalformedTrafficCalcConfigException; |
4 | 6 | import com.uid2.shared.ApplicationVersion; |
5 | 7 | import com.uid2.shared.Utils; |
6 | 8 | import com.uid2.shared.attest.AttestationResponseHandler; |
|
27 | 29 | import io.vertx.config.ConfigRetriever; |
28 | 30 | import io.vertx.core.*; |
29 | 31 | import io.vertx.core.http.HttpServerOptions; |
30 | | -import io.vertx.core.http.impl.HttpUtils; |
31 | 32 | import io.vertx.core.json.JsonObject; |
32 | 33 | import io.vertx.micrometer.MetricsDomain; |
33 | 34 | import org.slf4j.Logger; |
@@ -271,39 +272,42 @@ public void run(String[] args) throws IOException { |
271 | 272 | futs.add((this.uploadLastDelta(cs, logProducer, cloudSyncVerticle.eventUpload(), cloudSyncVerticle.eventRefresh()))); |
272 | 273 | } |
273 | 274 |
|
274 | | - // Deploy SQS producer if enabled |
| 275 | + // deploy sqs producer if enabled |
275 | 276 | if (this.enqueueSqsEnabled) { |
276 | | - LOGGER.info("SQS enabled, deploying OptOutSqsLogProducer"); |
| 277 | + LOGGER.info("sqs enabled, deploying OptOutSqsLogProducer"); |
277 | 278 | try { |
278 | | - // Create SQS-specific cloud sync with custom folder (default: "sqs-delta") |
| 279 | + // sqs delta production uses a separate s3 folder (default: "sqs-delta") |
| 280 | + // OptOutCloudSync reads from optout_s3_folder, so we override it with optout_sqs_s3_folder |
279 | 281 | String sqsFolder = this.config.getString(Const.Config.OptOutSqsS3FolderProp, "sqs-delta"); |
280 | | - LOGGER.info("SQS Config - optout_sqs_s3_folder: {}, will override optout_s3_folder to: {}", |
281 | | - sqsFolder, sqsFolder); |
282 | | - JsonObject sqsConfig = new JsonObject().mergeIn(this.config) |
| 282 | + JsonObject sqsCloudSyncConfig = new JsonObject().mergeIn(this.config) |
283 | 283 | .put(Const.Config.OptOutS3FolderProp, sqsFolder); |
284 | | - LOGGER.info("SQS Config after merge - optout_s3_folder: {}", sqsConfig.getString(Const.Config.OptOutS3FolderProp)); |
285 | | - OptOutCloudSync sqsCs = new OptOutCloudSync(sqsConfig, true); |
| 284 | + OptOutCloudSync sqsCs = new OptOutCloudSync(sqsCloudSyncConfig, true); |
286 | 285 |
|
287 | | - // Create SQS-specific cloud storage instance (same bucket, different folder handling) |
| 286 | + // create cloud storage instances |
288 | 287 | ICloudStorage fsSqs; |
289 | 288 | boolean useStorageMock = this.config.getBoolean(Const.Config.StorageMockProp, false); |
290 | 289 | if (useStorageMock) { |
291 | | - // Reuse the same LocalStorageMock for testing |
292 | 290 | fsSqs = this.fsOptOut; |
293 | 291 | } else { |
294 | | - // Create fresh CloudStorage for SQS (no path conversion wrapper) |
295 | 292 | String optoutBucket = this.config.getString(Const.Config.OptOutS3BucketProp); |
296 | | - fsSqs = CloudUtils.createStorage(optoutBucket, sqsConfig); |
| 293 | + fsSqs = CloudUtils.createStorage(optoutBucket, this.config); |
297 | 294 | } |
298 | 295 |
|
299 | | - // Deploy SQS log producer with its own storage instance |
300 | | - OptOutSqsLogProducer sqsLogProducer = new OptOutSqsLogProducer(this.config, fsSqs, sqsCs); |
| 296 | + String optoutBucketDroppedRequests = this.config.getString(Const.Config.OptOutS3BucketDroppedRequestsProp); |
| 297 | + ICloudStorage fsSqsDroppedRequests = CloudUtils.createStorage(optoutBucketDroppedRequests, this.config); |
| 298 | + |
| 299 | + // deploy sqs log producer |
| 300 | + OptOutSqsLogProducer sqsLogProducer = new OptOutSqsLogProducer(this.config, fsSqs, fsSqsDroppedRequests, sqsCs, Const.Event.DeltaProduce, null); |
301 | 301 | futs.add(this.deploySingleInstance(sqsLogProducer)); |
302 | 302 |
|
303 | | - LOGGER.info("SQS log producer deployed - bucket: {}, folder: {}", |
| 303 | + LOGGER.info("sqs log producer deployed, bucket={}, folder={}", |
304 | 304 | this.config.getString(Const.Config.OptOutS3BucketProp), sqsFolder); |
305 | 305 | } catch (IOException e) { |
306 | | - LOGGER.error("Failed to initialize SQS log producer: " + e.getMessage(), e); |
| 306 | + LOGGER.error("circuit_breaker_config_error: failed to initialize sqs log producer, delta production will be disabled: {}", e.getMessage(), e); |
| 307 | + } catch (MalformedTrafficFilterConfigException e) { |
| 308 | + LOGGER.error("circuit_breaker_config_error: traffic filter config is malformed, delta production will be disabled: {}", e.getMessage(), e); |
| 309 | + } catch (MalformedTrafficCalcConfigException e) { |
| 310 | + LOGGER.error("circuit_breaker_config_error: traffic calc config is malformed, delta production will be disabled: {}", e.getMessage(), e); |
307 | 311 | } |
308 | 312 | } |
309 | 313 |
|
|
0 commit comments