Support sleep node in flows#13
Merged
Merged
Conversation
Enables pausing execution within a flow for a specified duration. This introduces a new `Sleep` node type in the flow engine, allowing for timed delays during flow execution. The duration is specified in the flow definition using human-readable format, leveraging the `humantime-serde` crate for easy parsing.
Introduces the ability to schedule flows to continue execution after a specified duration when encountering a sleep node. This is achieved by sending a `SchedulerCommand::ScheduleOnce` to the scheduler, which then triggers the flow execution to resume at the designated node after the delay. This change also modifies the store listener and the main function to pass the scheduler transmitter to the `execute_flows` function, allowing scheduled executions from reactive flows.
Moves the scheduler module from its own directory into the flow_engine directory. This change improves project organization and reflects that the scheduler is closely related and used by the flow engine. It also ensures that the flow engine has access to scheduling capabilities. This change also updates references to the scheduler in other modules.
This commit introduces an `id` field to the `Flow` struct, enabling unique identification of flows. The `Flow::new` function now requires an `id` parameter, which is stored within the `Flow` struct. The flow loader and tests are updated to use the new `id` field.
Adds a `FlowRegistry` to manage and retrieve flows, replacing direct vector access. This change improves flow organization and lookup efficiency, especially for scheduled flows. The scheduler now uses the registry to fetch flows by id, and the store listener uses it to access reactive flows. This centralizes flow management and reduces code duplication.
Addresses issues where spawned tasks were incorrectly consuming variables. By cloning the `duration` field from the `Sleep` struct is unnecesary because `duration` implements the `Copy` trait and removing unnecessary clones of tx channels, it ensures that ownership is properly managed.
Adds the ability to execute flows starting from a specified node, rather than always from the beginning. This enhances flexibility and allows resuming flows from interruption points. Introduces the `execute_flow` function to facilitate execution from a specific node. Refactors the `execute_flows` function and the flow engine to support this new functionality. Adds logging to aid in debugging and monitoring flow execution. Also moves command dispatching to its own function to remove duplication.
Updates dependencies to their latest versions. Removes some unnecessary dependencies, improving the project's dependency footprint.
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.
idtoFlow