Schedule sunrise/sunset events#15
Merged
Merged
Conversation
Introduces the `Schedule` enum to represent different scheduling options, including cron expressions and sunrise/sunset events. Adds deserialization logic for the `Schedule` enum, allowing it to be parsed from JSON configurations. This enhances the flexibility of defining flow execution schedules.
Introduces a scheduling mechanism that supports cron expressions and solar events (sunrise/sunset) with offsets. This allows for more flexible and dynamic trigger conditions.
Updates the Flow struct to use the Schedule enum instead of a String for representing schedules. This change improves type safety and allows for more structured schedule definitions, including cron expressions and sunrise/sunset based schedules. Also, validates cron expressions during deserialization, preventing invalid schedules from being loaded. Adds a Display implementation for the Schedule enum, making it easier to log and debug scheduled flows.
Moves the `Weekday` enum from the `flow_engine` module to the `domain` module to improve code organization and reusability. This change centralizes the `Weekday` definition, making it accessible to other parts of the application that may need to work with weekdays.
The `ToWeekday` trait and its implementation for `chrono::DateTime` were previously defined in `expression.rs`. This commit moves them to a new `date_time_ext.rs` file within the `extensions` module. This change promotes code reusability and maintains a cleaner structure.
Moves the `WeekdayCondition` enum from the `flow_engine` module to the `domain` module. This change promotes better separation of concerns by defining `WeekdayCondition` alongside other domain-specific types, enhancing code organization and reducing dependencies within the `flow_engine`.
Moves the `Time` struct from the flow engine to the domain layer to promote code reuse and align with domain-driven design principles.
Refactors the Context struct to use a builder pattern for easier and more flexible initialization. This change removes the direct `new` and `new_with_now` methods and introduces a `ContextBuilder` struct. This allows for optional parameters during context creation, improving code readability and maintainability. The `execute_flow` and `execute_flows` functions are updated to use the new builder pattern.
Changes scheduler to use local time instead of UTC when calculating upcoming sunset events. This ensures schedules are triggered according to the user's timezone.
Updates the sunset schedule offset to use minutes instead of seconds. This provides a more intuitive and practical way to configure the desired offset for sunset events.
Allows schedules to be defined without a specific weekday. This introduces an 'Any' weekday condition, enabling schedule definitions that apply regardless of the day of the week. It also handles cases where 'when' is missing in the schedule definition, defaulting to the 'Any' condition.
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.
Scheduleas an abstraction overcron::Schedulewith support for sunrise and sunset eventsContextto make tests more readable