Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flow configuration separation #982

Merged
merged 16 commits into from
Dec 27, 2024
Merged

Conversation

rmn-boiko
Copy link
Contributor

@rmn-boiko rmn-boiko commented Dec 10, 2024

Description

Closes: #987
#938

Checklist before requesting a review

@rmn-boiko rmn-boiko self-assigned this Dec 10, 2024
@rmn-boiko rmn-boiko force-pushed the feat/119-config-separation branch 5 times, most recently from 9db7d93 to 4590b5c Compare December 10, 2024 16:06
@rmn-boiko rmn-boiko marked this pull request as ready for review December 10, 2024 16:26
@rmn-boiko rmn-boiko force-pushed the feat/119-config-separation branch from 4590b5c to 957e77b Compare December 10, 2024 17:07
@rmn-boiko rmn-boiko force-pushed the feat/119-config-separation branch from a6ae340 to 08ca7ee Compare December 11, 2024 12:26
@zaychenko-sergei
Copy link
Contributor

Prepare a migration to clean old configuration events

@zaychenko-sergei
Copy link
Contributor

This logic looks obsolete. I think we should restore auto-polling flows based on active triggers, the configuration cannot be in disabled state anymore - it's just a set of properties to take with the triggered flow.

  #[tracing::instrument(level = "debug", skip_all)]
    async fn restore_auto_polling_flows_from_configurations(
        &self,
        target_catalog: &Catalog,
        start_time: DateTime<Utc>,
    ) -> Result<(), InternalError> {
        let flow_configuration_service = target_catalog
            .get_one::<dyn FlowConfigurationService>()
            .unwrap();
        let flow_event_store = target_catalog.get_one::<dyn FlowEventStore>().unwrap();

        // Query all enabled flow configurations
        let enabled_configurations: Vec<_> = flow_configuration_service
            .list_enabled_configurations()
            .try_collect()
            .await?;

        // Split configs by those which have a schedule or different rules
        let (schedule_configs, non_schedule_configs): (Vec<_>, Vec<_>) = enabled_configurations
            .into_iter()
            .partition(|config| matches!(config.rule, FlowConfigurationRule::Schedule(_)));

        let scheduling_helper = target_catalog.get_one::<FlowSchedulingHelper>().unwrap();

        // Activate all configs, ensuring schedule configs precedes non-schedule configs
        // (this i.e. forces all root datasets to be updated earlier than the derived)
        //
        // Thought: maybe we need topological sorting by derived relations as well to
        // optimize the initial execution order, but batching rules may work just fine
        for enabled_config in schedule_configs
            .into_iter()
            .chain(non_schedule_configs.into_iter())
        {
            // Do not re-trigger the flow that has already triggered
            let maybe_pending_flow_id = flow_event_store
                .try_get_pending_flow(&enabled_config.flow_key)
                .await?;
            if maybe_pending_flow_id.is_none() {
                scheduling_helper
                    .activate_flow_configuration(
                        start_time,
                        enabled_config.flow_key,
                        enabled_config.rule,
                    )
                    .await?;
            }
        }

        Ok(())
    }

@rmn-boiko rmn-boiko force-pushed the feat/119-config-separation branch from 53ba150 to 8cdb6ec Compare December 13, 2024 10:40
@rmn-boiko rmn-boiko force-pushed the feat/119-config-separation branch from 8cdb6ec to 83ae80f Compare December 13, 2024 10:42
@rmn-boiko rmn-boiko requested a review from sergiimk December 16, 2024 13:46
@rmn-boiko rmn-boiko force-pushed the feat/119-config-separation branch from dfc1cd9 to bf0b10e Compare December 16, 2024 14:22
@rmn-boiko rmn-boiko force-pushed the feat/119-config-separation branch from 1f5763b to 1071488 Compare December 18, 2024 13:02
@rmn-boiko rmn-boiko force-pushed the feat/119-config-separation branch 2 times, most recently from b557ae4 to 9460bf6 Compare December 20, 2024 10:58
@rmn-boiko rmn-boiko force-pushed the feat/119-config-separation branch from 9460bf6 to 314564b Compare December 20, 2024 11:23
@zaychenko-sergei zaychenko-sergei merged commit 6637ed5 into master Dec 27, 2024
6 checks passed
@zaychenko-sergei zaychenko-sergei deleted the feat/119-config-separation branch December 27, 2024 10:29
@rmn-boiko rmn-boiko linked an issue Jan 3, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

API for account flow list does not work correctly Separate flow configuration from schedules
3 participants