Repository navigation
Add ChangeInterval to change a running action's interval [minor] - #109
Merged
Merged
Conversation
The README's "Dynamic Interval Adjustment" example assigned to the init-only IntervalActionOptions.ActionInterval, which does not compile, and the instance never re-read its options anyway. ChangeInterval sets the interval under the lock; the next poll measures it from the kept last run, so a run in progress is not interrupted and no state is lost. Fixes #80 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW59k83EYpQhgtoH5Qc
# Conflicts: # CLAUDE.md
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Fixes #80
What was wrong
The README's "Dynamic Interval Adjustment" example assigns to
IntervalActionOptions.ActionInterval, which isinit-only, so it fails to compile with CS8852. It would also have done nothing, because the instance copies its options once inStartand never reads them again. No public API could change the interval. The only way wasStop()followed by a newStart(...), and that loses the last-run timestamp and any pending failure.Change
IntervalAction.ChangeInterval(TimeSpan)sets the instance'sActionIntervalunder the lock. Every read of that field already happens under the lock:TryRun,HasIntervalElapsed, and the FromLastCompletion wait extension.LastRunTimestamp. If the run is already overdue under the new interval, it starts on the next poll; otherwise it waits out the rest. A run in progress is not interrupted. A negative value stops the action from running, the same as it does inStart.ChangeInterval, and the method is in the API table. A line in CLAUDE.md notes the new invariant.The issue's other point, the README rows for
IsRunning/Options, had already been removed onmain.Tagged
[minor]because this adds public API.Tests
ChangeIntervalAppliesToTheNextPollMeasuredFromTheLastRun(both interval types): a shorter interval makes an already-elapsed run due.ChangeIntervalToALongerIntervalHoldsOffARunThatWasDueChangeIntervalSpeedsUpARunningAction: end to end against a live polling loop.With
ChangeIntervalturned into a no-op, all four fail. With the fix, the full suite passes (66/66, net10.0), and a Release build of the solution succeeds across all target frameworks with no warnings.Generated by Claude Code