use try_send for dispatching actions
@@ -115,23 +115,33 @@ pub async fn daemon(
ActixEventBus {
callback: move |action| {
let action = Arc::new(action);
- match action.id.as_ref() {
+ let send_result = match action.id.as_ref() {
"archive" => archive_executor_addr
- .do_send(ActionMessage { action, failed_attempts: 0 }),
+ .try_send(ActionMessage { action, failed_attempts: 0 })
+ .map_err(|err| format!("Error sending message to 'archive' executor. Err: {:?}", err)),
"icinga2" => icinga2_executor_addr
- .do_send(ActionMessage { action, failed_attempts: 0 }),
+ .try_send(ActionMessage { action, failed_attempts: 0 })
+ .map_err(|err| format!("Error sending message to 'icinga2' executor. Err: {:?}", err)),
"director" => director_executor_addr
- .do_send(ActionMessage { action, failed_attempts: 0 }),
+ .try_send(ActionMessage { action, failed_attempts: 0 })
+ .map_err(|err| format!("Error sending message to 'director' executor. Err: {:?}", err)),
"script" => script_executor_addr
- .do_send(ActionMessage { action, failed_attempts: 0 }),
+ .try_send(ActionMessage { action, failed_attempts: 0 })
+ .map_err(|err| format!("Error sending message to 'script' executor. Err: {:?}", err)),
"foreach" => foreach_executor_addr_clone
- .do_send(ActionMessage { action, failed_attempts: 0 }),
+ .try_send(ActionMessage { action, failed_attempts: 0 })
+ .map_err(|err| format!("Error sending message to 'foreach' executor. Err: {:?}", err)),
"logger" => logger_executor_addr
- .do_send(ActionMessage { action, failed_attempts: 0 }),
+ .try_send(ActionMessage { action, failed_attempts: 0 })
+ .map_err(|err| format!("Error sending message to 'logger' executor. Err: {:?}", err)),
"elasticsearch" => elasticsearch_executor_addr
- .do_send(ActionMessage { action, failed_attempts: 0 }),
- _ => error!("There are not executors for action id [{}]", &action.id),
+ .try_send(ActionMessage { action, failed_attempts: 0 })
+ .map_err(|err| format!("Error sending message to 'elasticsearch' executor. Err: {:?}", err)),
+ _ => Err(format!("There are not executors for action id [{}]", &action.id)),
};
+ if let Err(error_message) = send_result {
+ error!("{}", error_message)
+ }
},
};
Arc::new(event_bus)
