use of com.walmartlabs.concord.policyengine.ProcessTimeoutRule in project concord by walmartlabs.
the class ProcessTimeoutPolicyApplier method apply.
@Override
public void apply(Payload payload, PolicyEngine policy) {
ProcessKey processKey = payload.getProcessKey();
Map<String, Object> cfg = payload.getHeader(Payload.CONFIGURATION);
if (cfg == null) {
return;
}
Object processTimeout = cfg.get(Constants.Request.PROCESS_TIMEOUT);
if (processTimeout == null) {
return;
}
CheckResult<ProcessTimeoutRule, Object> result = policy.getProcessTimeoutPolicy().check(processTimeout);
result.getDeny().forEach(i -> {
policyDeny.inc();
String msg = i.getRule().getMsg() != null ? i.getRule().getMsg() : DEFAULT_PROCESS_TIMEOUT_MSG;
Object actualTimeout = i.getEntity();
String limit = i.getRule().getMax();
logManager.error(processKey, MessageFormat.format(msg, actualTimeout, limit));
});
if (!result.getDeny().isEmpty()) {
throw new ProcessException(processKey, "'processTimeout' value policy violation");
}
}
Aggregations