Class AutoFetch
java.lang.Object
io.github.jbastgen.stemma.app.git.AutoFetch
Feature 54: when the repositories are fetched by themselves. This class only decides when (a repository is due
every N minutes, a failure makes it wait twice as long each time, up to an hour);
MainView runs the fetches and
RealRepoController.autoFetch(boolean, java.util.function.Consumer<io.github.jbastgen.stemma.app.git.AutoFetch.Outcome>) does the work. Free of JavaFX, so the rules can be tested with a fake clock.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordWhat one automatic fetch did, for the policy and for the single message to the user. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether the repository is due now and no fetch of it is running.booleanThe fetch failed: the next try comes after twice the interval, then four times, … but never later than an hour (and never earlier than the interval itself, which can be longer than an hour).voidForgets a repository that was closed.static Durationinterval(int minutes) The interval from the settings, kept inside what makes sense.voidreset()Asks for the repository to be fetched at the next opportunity (e.g. after the settings changed).voidA fetch starts: no second one for the same repository until it is over.voidThe fetch worked: back to the normal interval.
-
Field Details
-
MIN_MINUTES
public static final int MIN_MINUTES- See Also:
-
MAX_MINUTES
public static final int MAX_MINUTES- See Also:
-
-
Constructor Details
-
AutoFetch
public AutoFetch()
-
-
Method Details
-
interval
The interval from the settings, kept inside what makes sense. -
due
Whether the repository is due now and no fetch of it is running. The first call of a new repository starts its first wait. -
started
A fetch starts: no second one for the same repository until it is over. -
succeeded
The fetch worked: back to the normal interval. -
failed
The fetch failed: the next try comes after twice the interval, then four times, … but never later than an hour (and never earlier than the interval itself, which can be longer than an hour).- Returns:
- whether the user has not been told yet; true once per series of failures
-
forget
Forgets a repository that was closed. -
reset
public void reset()Asks for the repository to be fetched at the next opportunity (e.g. after the settings changed).
-