Repository: influxdata/influxdb
File: influxdb3_processing_engine/src/plugins.rs (Rust)

Code before:
                    errors.push(format!("invalid database name: {}", db_name));
                    continue;
                };

                if let Err(e) = self
                    .write_buffer
                    .write_lp(
                        namespace_name,
                        lines.join("\n").as_str(),
                        Time::from_timestamp_nanos(ingest_time.as_nanos() as i64),
                        false,
                        Precision::Nanosecond,
                        false,
                    )
                    .await
                {
                    errors.push(format!("error writing back lines to {}: {}", db_name, e));
                }
            }

            errors
        }
    }

    enum Schedule {
        Cron(OwnedScheduleIterator<Utc>),
        Every(Duration),
    }

    enum PluginNextState {
        SuccessfulRun,
        LogError(String),
        Disable(Arc<TriggerDefinition>),
    }

    pub(crate) struct ScheduleTriggerRunner {
        schedule: Schedule,
        next_trigger_time: Option<DateTime<Utc>>,
    }

    impl ScheduleTriggerRunner {
        pub(crate) fn try_new(
            trigger_spec: &TriggerSpecificationDefinition,
            time_provider: Arc<dyn TimeProvider>,
        ) -> Result<Self, PluginError> {
            match trigger_spec {
                TriggerSpecificationDefinition::AllTablesWalWrite
                | TriggerSpecificationDefinition::SingleTableWalWrite { .. } => {
                    Err(anyhow!("shouldn't have table trigger for scheduled plugin").into())
                }
                TriggerSpecificationDefinition::RequestPath { .. } => {

Review comment (suggestion):
clippy got smart about significant difference in size of variants and suggested boxing instead.

It said that `Cron(OwnedScheduleIterator<Utc>)` required 288 bytes, whereas `Every(Duration)` was 16 bytes. This reduces the enum to 16 bytes.

Code after:
                    errors.push(format!("invalid database name: {}", db_name));
                    continue;
                };

                if let Err(e) = self
                    .write_buffer
                    .write_lp(
                        namespace_name,
                        lines.join("\n").as_str(),
                        Time::from_timestamp_nanos(ingest_time.as_nanos() as i64),
                        false,
                        Precision::Nanosecond,
                        false,
                    )
                    .await
                {
                    errors.push(format!("error writing back lines to {}: {}", db_name, e));
                }
            }

            errors
        }
    }

    enum Schedule {
        Cron(Box<OwnedScheduleIterator<Utc>>),
        Every(Duration),
    }

    enum PluginNextState {
        SuccessfulRun,
        LogError(String),
        Disable(Arc<TriggerDefinition>),
    }

    pub(crate) struct ScheduleTriggerRunner {
        schedule: Schedule,
        next_trigger_time: Option<DateTime<Utc>>,
    }

    impl ScheduleTriggerRunner {
        pub(crate) fn try_new(
            trigger_spec: &TriggerSpecificationDefinition,
            time_provider: Arc<dyn TimeProvider>,
        ) -> Result<Self, PluginError> {
            match trigger_spec {
                TriggerSpecificationDefinition::AllTablesWalWrite
                | TriggerSpecificationDefinition::SingleTableWalWrite { .. } => {
                    Err(anyhow!("shouldn't have table trigger for scheduled plugin").into())
                }
                TriggerSpecificationDefinition::RequestPath { .. } => {