refactor: 🔨 remove comments about callbacks

This commit is contained in:
Lucas Colombo 2024-06-21 12:56:39 -03:00
parent 7849458963
commit b35cbe95ee
Signed by: lucas
GPG Key ID: EF34786CFEFFAE35
2 changed files with 12 additions and 18 deletions

View File

@ -319,24 +319,8 @@ pub trait Rustler: RustlerAccessor + Send + Sync {
/// should be called after the status of the rustler changes /// should be called after the status of the rustler changes
fn handle_status_change(&mut self) -> Result<()> { fn handle_status_change(&mut self) -> Result<()> {
match self.status() { match self.status() {
RustlerStatus::Disconnected => { RustlerStatus::Disconnected => self.set_last_stop(Some(Local::now())),
self.set_last_stop(Some(Local::now())); RustlerStatus::Connected => self.set_last_run(Some(Local::now())),
// if let Some(callbacks) = self.callbacks() {
// if let Some(on_disconnected) = callbacks.on_disconnected {
// on_disconnected()?;
// }
// }
}
RustlerStatus::Connected => {
self.set_last_run(Some(Local::now()));
// if let Some(callbacks) = self.callbacks() {
// if let Some(on_connected) = callbacks.on_connected {
// on_connected()?;
// }
// }
}
_ => {} _ => {}
}; };
@ -433,6 +417,11 @@ macro_rules! rustler_accessors {
fn next_run(&self) -> &$crate::rustlers::chrono::DateTime<$crate::rustlers::chrono::Local> { fn next_run(&self) -> &$crate::rustlers::chrono::DateTime<$crate::rustlers::chrono::Local> {
&self.next_run &self.next_run
} }
// TODO: Instead of next_run and next_stop, store the scheduling rules
// we can calculate the next run and next stop times from the rules, and will also be
// useful to decide if we should recover from a disconnection or not (we should only
// recover if the rules say we should be connected at the current time, otherwise we
// should stay disconnected, even if it was an abnormal disconnection)
fn set_next_run( fn set_next_run(
&mut self, &mut self,
next_run: $crate::rustlers::chrono::DateTime<$crate::rustlers::chrono::Local>, next_run: $crate::rustlers::chrono::DateTime<$crate::rustlers::chrono::Local>,

View File

@ -112,6 +112,11 @@ where
let mut publisher = self.publisher.clone(); let mut publisher = self.publisher.clone();
while let Some(msg) = receiver.recv().await { while let Some(msg) = receiver.recv().await {
match msg { match msg {
// TODO: if we want to restart a dead rustler, we should listen for a restart
// signal here and restart the rustler. The restart signal does not exist
// yet, so we will need to implement it and send it from rustlers when
// it makes sense to restart them (when we are sure we are not going to
// keep listening for quotes from the source feed, for example)
RustlerMsg::QuoteMsg(quote) => publisher.publish(quote).await?, RustlerMsg::QuoteMsg(quote) => publisher.publish(quote).await?,
} }
} }