(&mut self, action: NextGuildAction)
| 177 | |
| 178 | #[instrument(skip(self), fields(guild_id = self.guild_id.get(), action = action.span_info()))] |
| 179 | pub(crate) async fn handle_next_action(&mut self, action: NextGuildAction) -> bool { |
| 180 | match action { |
| 181 | NextGuildAction::GuildCommand(GuildCommand::Shutdown) => { |
| 182 | info!("got shutdown signal"); |
| 183 | return false; |
| 184 | } |
| 185 | NextGuildAction::GuildCommand(cmd) => { |
| 186 | self.handle_guild_command(cmd).await; |
| 187 | } |
| 188 | NextGuildAction::WorkerMessage(msg) => { |
| 189 | let Some(session) = &mut self.session else { |
| 190 | return true; |
| 191 | }; |
| 192 | |
| 193 | let events = session.handle_worker_msg(msg); |
| 194 | return self.handle_session_events(events).await; |
| 195 | } |
| 196 | NextGuildAction::CheckScheduledTasks => { |
| 197 | let tasks = self.scheduled_tasks_man.start_triggered_tasks().await; |
| 198 | for task in tasks { |
| 199 | self.dispatch_scheduled_task(task).await; |
| 200 | } |
| 201 | } |
| 202 | NextGuildAction::CheckIntervalTimers => { |
| 203 | let timers = self.interval_timers_man.trigger_timers().await; |
| 204 | for timer in timers { |
| 205 | self.dispatch_interval_timer(timer).await; |
| 206 | } |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | true |
| 211 | } |
| 212 | |
| 213 | pub(crate) async fn next_event(&mut self) -> Option<NextGuildAction> { |
| 214 | self.scheduled_tasks_man.init_next_task_time().await; |
no test coverage detected