Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Component
public class IgniteAlertConfigStore implements AlertsConfigStore {
private static final Logger logger = LoggerFactory.getLogger(IgniteAlertConfigStore.class);
// here it will be injected as a spring bean
@Autowired
private Ignite ignite;
@Override
public AlertConfigEntry getConfigForServiceIdCodeId(String serviceId, String codeId) {
return Optional.ofNullable(getAlertsConfigCache().get(serviceId + "_" + codeId))
.orElseThrow(() -> new ResourceNotFoundException(String.format("Alert config for %s with %s not found", serviceId,codeId)));
}
@Override
public void update(String serviceId, String codeId, AlertConfigEntry alertConfigEntry) {
getAlertsConfigCache().put(serviceId + "_" + codeId, alertConfigEntry);
}
@Override
public Optional<AlertConfigEntry> getConfigForServiceIdCodeIdCount(String serviceId, String codeId) {
return Optional.ofNullable(getAlertsConfigCache().get(serviceId + "_" + codeId));
}
public Cache<String, AlertConfigEntry> getAlertsConfigCache() {
return ignite.getOrCreateCache(CacheNames.AlertsConfig.name());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment