@Override public Optional<Long> getLatestStoredCounter(WorkflowInstance workflowInstance) throws IOException { final SortedSet<SequenceEvent> storedEvents = readEvents(workflowInstance); if (storedEvents.isEmpty()) { return Optional.empty(); } else { final SequenceEvent lastStoredEvent = storedEvents.last(); return Optional.of(lastStoredEvent.counter()); } }
private static StorageFactory storage(StorageFactory storage) { return (environment, stats) -> { if (isDevMode(environment.config())) { LOG.info("Running Styx in development mode, will use InMemStorage"); return new InMemStorage(); } else { return storage.apply(environment, stats); } }; }