Package io.datareplication.producer.feed
Interface FeedProducerJournalRepository
-
public interface FeedProducerJournalRepository
Repository to store rollback information for the feed producer.The feed producer uses this information to cleanly roll back partial changes in case of a crash or other interruption. The exact meaning of the stored fields is an implementation detail and might change (in a compatible way). The repository doesn't need to know what the fields mean, it just needs to save and load their values accurately.
This repository always stores either zero or one records.
Consistency Requirements
In addition tothe common requirements for all feed producer repositories
, all writes to this repository must be atomic:get()
may never observe a partially written or deleted state.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
FeedProducerJournalRepository.JournalState
The rollback information stored by the feed producer to allow clean rollbacks.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description @NonNull java.util.concurrent.CompletionStage<java.lang.Void>
delete()
Delete the currently stored journal state from the repository.@NonNull java.util.concurrent.CompletionStage<@NonNull java.util.Optional<@NonNull FeedProducerJournalRepository.JournalState>>
get()
Get the currently stored journal state from the repository.@NonNull java.util.concurrent.CompletionStage<java.lang.Void>
save(@NonNull FeedProducerJournalRepository.JournalState state)
Save the given journal state to the repository.
-
-
-
Method Detail
-
save
@NonNull @NonNull java.util.concurrent.CompletionStage<java.lang.Void> save(@NonNull @NonNull FeedProducerJournalRepository.JournalState state)
Save the given journal state to the repository.This replaces the current entry, if any.
- Parameters:
state
- the entry to save- Returns:
- CompletionStage
-
get
@NonNull @NonNull java.util.concurrent.CompletionStage<@NonNull java.util.Optional<@NonNull FeedProducerJournalRepository.JournalState>> get()
Get the currently stored journal state from the repository.This should either return the state passed to the most recent call to
save(JournalState)
orOptional.empty()
ifdelete()
was called most recently orsave(JournalState)
was never called- Returns:
- CompletionStage of the currently stored journal state
-
delete
@NonNull @NonNull java.util.concurrent.CompletionStage<java.lang.Void> delete()
Delete the currently stored journal state from the repository.If there's no current entry (i.e. whenever
get()
returns nothing), this method is a no-op.- Returns:
- CompletionStage
-
-