diff --git a/diff.patch b/diff.patch new file mode 100644 index 0000000..37fa035 --- /dev/null +++ b/diff.patch @@ -0,0 +1,117 @@ +diff --git a/workshop-baker/src/notify.rs b/workshop-baker/src/notify.rs +index 75bce82..ad56c66 100644 +--- a/workshop-baker/src/notify.rs ++++ b/workshop-baker/src/notify.rs +@@ -3,15 +3,15 @@ use crate::finalize::FinalizeConfig; + use crate::finalize::parse; + use crate::finalize::plugin; + use crate::finalize::plugin::fetch; +-use crate::notify::types::BundledNotifyEvent; ++use crate::notify::types::BundledNotificationEvent; + use crate::notify::types::NOTIFY_TEMPORARY_DELAY_FACTOR; + use crate::notify::types::NOTIFY_TEMPORARY_DELAY_TIME; + use crate::notify::types::NOTIFY_TEMPORARY_MAX_TIME; + use crate::notify::types::NotificationRulesMap; +-use crate::notify::types::NotifyEvent; +-use crate::notify::types::NotifyEventReceiver; +-use crate::notify::types::NotifyEventSender; +-use crate::notify::types::NotifyPluginMap; ++use crate::notify::types::NotificationEvent; ++use crate::notify::types::NotificationEventReceiver; ++use crate::notify::types::NotificationEventSender; ++use crate::notify::types::NotificationPluginMap; + use crate::{EventSender, ExecutionContext}; + use std::collections::HashSet; + use std::path::Path; +@@ -46,8 +46,8 @@ pub async fn notify( + finalize_path: &Path, + ctx: &mut ExecutionContext, + event_tx: EventSender, +- notifyevent_rx: &mut NotifyEventReceiver, +- notifyevent_tx: NotifyEventSender, ++ notifyevent_rx: &mut NotificationEventReceiver, ++ notifyevent_tx: NotificationEventSender, + ) -> anyhow::Result<()> { + let mut finalize = parse(finalize_path)?; + validate(&finalize)?; +@@ -114,10 +114,11 @@ pub async fn notify( + } + + fn notification_handler( +- plugins: &NotifyPluginMap, ++ plugins: &NotificationPluginMap, + config: &NotificationRulesMap, +- event: &BundledNotifyEvent, ++ event: &BundledNotificationEvent, + ) -> Result<(), NotifyError> { ++ + todo!(); + } + +@@ -132,7 +133,7 @@ fn wait_time(group_period: u32, group_watermark: u32, count: u32) -> f32 { + } + + // calculate p^(m-l)*t as notification delay +-fn notify_delay(event: &NotifyEvent) -> std::time::Duration { ++fn notify_delay(event: &NotificationEvent) -> std::time::Duration { + let exponent = (event.max_lives - event.lives) as i32; + if exponent < 0 { + log::warn!( +diff --git a/workshop-baker/src/notify/types.rs b/workshop-baker/src/notify/types.rs +index b852dfb..d6ccfb7 100644 +--- a/workshop-baker/src/notify/types.rs ++++ b/workshop-baker/src/notify/types.rs +@@ -39,13 +39,13 @@ pub struct NotificationRule{ + pub type Priority = u32; + pub type Method = String; + pub type NotificationRulesMap = HashMap>>; +-pub type BundledNotifyEvent = Vec; +-pub type NotifyEventReceiver = tokio::sync::mpsc::Receiver; +-pub type NotifyEventSender = tokio::sync::mpsc::Sender; +-pub type NotifyPluginMap = HashMap; ++pub type BundledNotificationEvent = Vec; ++pub type NotificationEventReceiver = tokio::sync::mpsc::Receiver; ++pub type NotificationEventSender = tokio::sync::mpsc::Sender; ++pub type NotificationPluginMap = HashMap; + + #[derive(Debug, Clone, Serialize)] +-pub struct NotifyEvent { ++pub struct NotificationEvent { + pub id: Uuid, + pub stage: StagePhase, + pub substage: String, +@@ -58,21 +58,21 @@ pub struct NotifyEvent { + pub target: HashSet, // Target audience + } + +-impl Hash for NotifyEvent { ++impl Hash for NotificationEvent { + fn hash(&self, state: &mut H) { + self.id.hash(state); + } + } + +-impl PartialEq for NotifyEvent { ++impl PartialEq for NotificationEvent { + fn eq(&self, other: &Self) -> bool { + self.id == other.id + } + } + +-impl Eq for NotifyEvent {} ++impl Eq for NotificationEvent {} + +-impl PartialOrd for NotifyEvent { ++impl PartialOrd for NotificationEvent { + fn partial_cmp(&self, other: &Self) -> Option { + Some( + self.effective_priority +@@ -83,7 +83,7 @@ impl PartialOrd for NotifyEvent { + } + } + +-impl Ord for NotifyEvent { ++impl Ord for NotificationEvent { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.partial_cmp(other).unwrap() + } diff --git a/workshop-baker/src/notify.rs b/workshop-baker/src/notify.rs index 75bce82..ad56c66 100644 --- a/workshop-baker/src/notify.rs +++ b/workshop-baker/src/notify.rs @@ -3,15 +3,15 @@ use crate::finalize::FinalizeConfig; use crate::finalize::parse; use crate::finalize::plugin; use crate::finalize::plugin::fetch; -use crate::notify::types::BundledNotifyEvent; +use crate::notify::types::BundledNotificationEvent; use crate::notify::types::NOTIFY_TEMPORARY_DELAY_FACTOR; use crate::notify::types::NOTIFY_TEMPORARY_DELAY_TIME; use crate::notify::types::NOTIFY_TEMPORARY_MAX_TIME; use crate::notify::types::NotificationRulesMap; -use crate::notify::types::NotifyEvent; -use crate::notify::types::NotifyEventReceiver; -use crate::notify::types::NotifyEventSender; -use crate::notify::types::NotifyPluginMap; +use crate::notify::types::NotificationEvent; +use crate::notify::types::NotificationEventReceiver; +use crate::notify::types::NotificationEventSender; +use crate::notify::types::NotificationPluginMap; use crate::{EventSender, ExecutionContext}; use std::collections::HashSet; use std::path::Path; @@ -46,8 +46,8 @@ pub async fn notify( finalize_path: &Path, ctx: &mut ExecutionContext, event_tx: EventSender, - notifyevent_rx: &mut NotifyEventReceiver, - notifyevent_tx: NotifyEventSender, + notifyevent_rx: &mut NotificationEventReceiver, + notifyevent_tx: NotificationEventSender, ) -> anyhow::Result<()> { let mut finalize = parse(finalize_path)?; validate(&finalize)?; @@ -114,10 +114,11 @@ pub async fn notify( } fn notification_handler( - plugins: &NotifyPluginMap, + plugins: &NotificationPluginMap, config: &NotificationRulesMap, - event: &BundledNotifyEvent, + event: &BundledNotificationEvent, ) -> Result<(), NotifyError> { + todo!(); } @@ -132,7 +133,7 @@ fn wait_time(group_period: u32, group_watermark: u32, count: u32) -> f32 { } // calculate p^(m-l)*t as notification delay -fn notify_delay(event: &NotifyEvent) -> std::time::Duration { +fn notify_delay(event: &NotificationEvent) -> std::time::Duration { let exponent = (event.max_lives - event.lives) as i32; if exponent < 0 { log::warn!( diff --git a/workshop-baker/src/notify/types.rs b/workshop-baker/src/notify/types.rs index b852dfb..d6ccfb7 100644 --- a/workshop-baker/src/notify/types.rs +++ b/workshop-baker/src/notify/types.rs @@ -39,13 +39,13 @@ pub struct NotificationRule{ pub type Priority = u32; pub type Method = String; pub type NotificationRulesMap = HashMap>>; -pub type BundledNotifyEvent = Vec; -pub type NotifyEventReceiver = tokio::sync::mpsc::Receiver; -pub type NotifyEventSender = tokio::sync::mpsc::Sender; -pub type NotifyPluginMap = HashMap; +pub type BundledNotificationEvent = Vec; +pub type NotificationEventReceiver = tokio::sync::mpsc::Receiver; +pub type NotificationEventSender = tokio::sync::mpsc::Sender; +pub type NotificationPluginMap = HashMap; #[derive(Debug, Clone, Serialize)] -pub struct NotifyEvent { +pub struct NotificationEvent { pub id: Uuid, pub stage: StagePhase, pub substage: String, @@ -58,21 +58,21 @@ pub struct NotifyEvent { pub target: HashSet, // Target audience } -impl Hash for NotifyEvent { +impl Hash for NotificationEvent { fn hash(&self, state: &mut H) { self.id.hash(state); } } -impl PartialEq for NotifyEvent { +impl PartialEq for NotificationEvent { fn eq(&self, other: &Self) -> bool { self.id == other.id } } -impl Eq for NotifyEvent {} +impl Eq for NotificationEvent {} -impl PartialOrd for NotifyEvent { +impl PartialOrd for NotificationEvent { fn partial_cmp(&self, other: &Self) -> Option { Some( self.effective_priority @@ -83,7 +83,7 @@ impl PartialOrd for NotifyEvent { } } -impl Ord for NotifyEvent { +impl Ord for NotificationEvent { fn cmp(&self, other: &Self) -> std::cmp::Ordering { self.partial_cmp(other).unwrap() }