-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add framework for scheduled jobs; convert auto-refresh
This PR adds a framework for "scheduled jobs" and passes "TickMsg" messages to the Update() function based on an interval set in the root.go file (currently 1s per "tick"). This also converts the auto-refresh to a scheduled job, and sets a slice of initial `[]*scheduledJob`. Each scheduled job is made up of: ``` type scheduledJob struct { jobMsg tea.Cmd lastRun time.Time frequency time.Duration } ``` And the `jobMsg` `tea.Cmd` is run if the `lastRun` is further than `frequency` in the past. Each scheduled job is evalusted when a `TickMsg` is received. The auto refresh feature is implemented as: ``` { jobMsg: func() tea.Msg { return PollIncidentsMsg{} }, frequency: time.Second * 15, }, ``` This job is added to the list of initial secheduled jobs on startup. Currently, the job is run every 15 seconds, and if "auto-refresh" is enabled, then incidents are updated. In the future this will be converted to adding or removing the scheduled job from the job list, rather than parsing if "auto-refresh" is true or not, and `autoRefresh bool` removed from the model. Signed-off-by: Chris Collins <[email protected]>
- Loading branch information
Showing
4 changed files
with
38 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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