Skip to content

Commit

Permalink
Post-review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
VeryExtraordinaryUsername committed Feb 28, 2024
1 parent 87cc1fc commit 74c9a70
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import org.prebid.server.json.JsonLogic;
import org.prebid.server.metric.MetricName;
import org.prebid.server.metric.Metrics;
import org.prebid.server.settings.SettingsCache;
import org.prebid.server.settings.model.activity.privacy.AccountUSCustomLogicModuleConfig;

import java.util.Collection;
Expand All @@ -46,18 +45,13 @@ public class USCustomLogicModuleCreator implements PrivacyModuleCreator {

public USCustomLogicModuleCreator(USCustomLogicGppReaderFactory gppReaderFactory,
JsonLogic jsonLogic,
Integer cacheTtl,
Integer cacheSize,
int jitter,
Map<String, JsonLogicNode> jsonLogicNodesCache,
Metrics metrics) {

this.gppReaderFactory = Objects.requireNonNull(gppReaderFactory);
this.jsonLogic = Objects.requireNonNull(jsonLogic);
this.metrics = Objects.requireNonNull(metrics);

jsonLogicNodesCache = cacheTtl != null && cacheSize != null
? SettingsCache.createCache(cacheTtl, cacheSize, jitter)
: null;
this.jsonLogicNodesCache = jsonLogicNodesCache;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.prebid.server.spring.config;

import io.github.jamsesso.jsonlogic.ast.JsonLogicNode;
import org.prebid.server.activity.infrastructure.creator.ActivityInfrastructureCreator;
import org.prebid.server.activity.infrastructure.creator.ActivityRuleFactory;
import org.prebid.server.activity.infrastructure.creator.privacy.PrivacyModuleCreator;
Expand All @@ -13,11 +14,13 @@
import org.prebid.server.activity.infrastructure.creator.rule.RuleCreator;
import org.prebid.server.json.JsonLogic;
import org.prebid.server.metric.Metrics;
import org.prebid.server.settings.SettingsCache;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.List;
import java.util.Map;

@Configuration
public class ActivityInfrastructureConfiguration {
Expand Down Expand Up @@ -47,17 +50,26 @@ USCustomLogicGppReaderFactory usCustomLogicGppReaderFactory() {
return new USCustomLogicGppReaderFactory();
}

@Bean
Map<String, JsonLogicNode> jsonLogicNodesCache(
@Value("${settings.in-memory-cache.ttl-seconds:#{null}}") Integer ttlSeconds,
@Value("${settings.in-memory-cache.cache-size:#{null}}") Integer cacheSize,
@Value("${settings.in-memory-cache.cache-size:0}") int jitter) {

return ttlSeconds != null && cacheSize != null
? SettingsCache.createCache(ttlSeconds, cacheSize, jitter)
: null;
}

@Bean
USCustomLogicModuleCreator usCustomLogicModuleCreator(
USCustomLogicGppReaderFactory gppReaderFactory,
JsonLogic jsonLogic,
@Value("${settings.in-memory-cache.ttl-seconds:#{null}}") Integer ttlSeconds,
@Value("${settings.in-memory-cache.cache-size:#{null}}") Integer cacheSize,
@Value("${settings.in-memory-cache.cache-size:0}") int jitter,
Map<String, JsonLogicNode> jsonLogicNodesCache,
Metrics metrics) {

return new USCustomLogicModuleCreator(
gppReaderFactory, jsonLogic, ttlSeconds, cacheSize, jitter, metrics);
gppReaderFactory, jsonLogic, jsonLogicNodesCache, metrics);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void setUp() {
.willReturn(new USNationalGppReader(null));
given(jsonLogic.parse(any())).willReturn(JsonLogicBoolean.TRUE);

target = new USCustomLogicModuleCreator(gppReaderFactory, jsonLogic, null, null, 0, metrics);
target = new USCustomLogicModuleCreator(gppReaderFactory, jsonLogic, null, metrics);
}

@Test
Expand Down

0 comments on commit 74c9a70

Please sign in to comment.