Today if you wanna do more than on check you can use the SecurityService.getCheckExecutor() or SecurityService.getAsyncCheckExecutor() but unfortunately, internally both are still doing one metrics request per check. Would be also to send all metrics together to the MetricsService so it can automagic merge it in only one request. SyncSecurityCheckExecutor
public Map<String, SecurityCheckResult> execute() { |
final Map<String, SecurityCheckResult> results = new HashMap<>(); |
|
for (SecurityCheck check : getChecks()) { |
SecurityCheckResult result = check.test(getContext()); |
results.put(check.getName(), result); |
publishResultMetrics(result); |
} |
|
return results; |
}
|
AsyncSecurityCheckExecutor
public Map<String, Future<SecurityCheckResult>> execute() { |
|
final MetricsService metricsService = getMetricsService(); |
final Map<String, Future<SecurityCheckResult>> res = new HashMap<>(); |
|
for (final SecurityCheck check : getChecks()) { |
res.put(check.getName(), (executorService.submit(() -> { |
final SecurityCheckResult result = check.test(getContext()); |
if (metricsService != null) { |
metricsService.publish(new SecurityCheckResultMetric(result)); |
} |
return result; |
}))); |
} |
|
return res; |
}
|
|