Enum holochain::conductor::manager::ManagedTaskError
source · pub enum ManagedTaskError {
Conductor(Box<ConductorError>),
Io(Error),
Join(JoinError),
Recv(RecvError),
}
Expand description
An error that is thrown from within a managed task
Variants§
Implementations§
source§impl ManagedTaskError
impl ManagedTaskError
sourcepub fn is_recoverable(&self) -> bool
pub fn is_recoverable(&self) -> bool
Examples found in repository?
src/conductor/manager/mod.rs (line 210)
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288
async fn run(
conductor: ConductorHandle,
mut new_task_channel: mpsc::Receiver<ManagedTaskAdd>,
) -> TaskManagerResult {
let mut task_manager = TaskManager::new();
// Need to have at least one item in the stream or it will exit early
if let Some(new_task) = new_task_channel.recv().await {
task_manager.stream.push(new_task);
} else {
error!("All senders to task manager were dropped before starting");
return Err(TaskManagerError::TaskManagerFailedToStart);
}
loop {
tokio::select! {
Some(new_task) = new_task_channel.recv() => {
task_manager.stream.push(new_task);
tracing::debug!("Task added. Total tasks: {}", task_manager.stream.len());
}
result = task_manager.stream.next() => {
tracing::debug!("Task completed. Total tasks: {}", task_manager.stream.len());
match result {
Some(TaskOutcome::NewTask(new_task)) => task_manager.stream.push(new_task),
Some(TaskOutcome::LogInfo(context)) => {
debug!("Managed task completed: {}", context)
}
Some(TaskOutcome::MinorError(error, context)) => {
error!("Minor error during managed task: {:?}\nContext: {}", error, context)
}
Some(TaskOutcome::ShutdownConductor(error, context)) => {
let error = match *error {
ManagedTaskError::Join(error) => {
match error.try_into_panic() {
Ok(reason) => {
// Resume the panic on the main task
std::panic::resume_unwind(reason);
}
Err(error) => ManagedTaskError::Join(error),
}
}
error => error,
};
error!("Shutting down conductor due to unrecoverable error: {:?}\nContext: {}", error, context);
return Err(TaskManagerError::Unrecoverable(Box::new(error)));
},
Some(TaskOutcome::StopApps(cell_id, error, context)) => {
tracing::error!("About to automatically stop apps");
let app_ids = conductor.list_running_apps_for_dependent_cell_id(&cell_id).await.map_err(TaskManagerError::internal)?;
if error.is_recoverable() {
conductor.remove_cells(&[cell_id]).await;
// The following message assumes that only the app_ids calculated will be paused, but other apps
// may have been paused as well.
tracing::error!(
"PAUSING the following apps due to a recoverable error: {:?}\nError: {:?}\nContext: {}",
app_ids,
error,
context
);
// MAYBE: it could be helpful to modify this function so that when providing Some(app_ids),
// you can also pass in a PausedAppReason override, so that the reason for the apps being paused
// can be set to the specific error message encountered here, rather than having to read it from
// the logs.
let delta = conductor.reconcile_app_status_with_cell_status(None).await.map_err(TaskManagerError::internal)?;
tracing::debug!(delta = ?delta);
tracing::error!("Apps paused.");
} else {
// Since the error is unrecoverable, we don't expect to be able to use this Cell anymore.
// Therefore, we disable every app which requires that cell.
tracing::error!(
"DISABLING the following apps due to an unrecoverable error: {:?}\nError: {:?}\nContext: {}",
app_ids,
error,
context
);
for app_id in app_ids.iter() {
conductor.clone().disable_app(app_id.to_string(), DisabledAppReason::Error(error.to_string())).await.map_err(TaskManagerError::internal)?;
}
tracing::error!("Apps disabled.");
}
},
Some(TaskOutcome::StopAppsWithDna(dna_hash, error, context)) => {
tracing::error!("About to automatically stop apps with dna {}", dna_hash);
let app_ids = conductor.list_running_apps_for_dependent_dna_hash(dna_hash.as_ref()).await.map_err(TaskManagerError::internal)?;
if error.is_recoverable() {
let cells_with_same_dna: Vec<_> = conductor.list_cell_ids(None).into_iter().filter(|id| id.dna_hash() == dna_hash.as_ref()).collect();
conductor.remove_cells(&cells_with_same_dna).await;
// The following message assumes that only the app_ids calculated will be paused, but other apps
// may have been paused as well.
tracing::error!(
"PAUSING the following apps due to a recoverable error: {:?}\nError: {:?}\nContext: {}",
app_ids,
error,
context
);
// MAYBE: it could be helpful to modify this function so that when providing Some(app_ids),
// you can also pass in a PausedAppReason override, so that the reason for the apps being paused
// can be set to the specific error message encountered here, rather than having to read it from
// the logs.
let delta = conductor.reconcile_app_status_with_cell_status(None).await.map_err(TaskManagerError::internal)?;
tracing::debug!(delta = ?delta);
tracing::error!("Apps paused.");
} else {
// Since the error is unrecoverable, we don't expect to be able to use this Cell anymore.
// Therefore, we disable every app which requires that cell.
tracing::error!(
"DISABLING the following apps due to an unrecoverable error: {:?}\nError: {:?}\nContext: {}",
app_ids,
error,
context
);
for app_id in app_ids.iter() {
conductor.clone().disable_app(app_id.to_string(), DisabledAppReason::Error(error.to_string())).await.map_err(TaskManagerError::internal)?;
}
tracing::error!("Apps disabled.");
}
},
None => return Ok(()),
}}
};
}
}
Trait Implementations§
source§impl Debug for ManagedTaskError
impl Debug for ManagedTaskError
source§impl Display for ManagedTaskError
impl Display for ManagedTaskError
source§impl Error for ManagedTaskError
impl Error for ManagedTaskError
source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl From<Box<ConductorError, Global>> for ManagedTaskError
impl From<Box<ConductorError, Global>> for ManagedTaskError
source§fn from(source: Box<ConductorError>) -> Self
fn from(source: Box<ConductorError>) -> Self
Converts to this type from the input type.
source§impl From<Error> for ManagedTaskError
impl From<Error> for ManagedTaskError
source§impl From<JoinError> for ManagedTaskError
impl From<JoinError> for ManagedTaskError
Auto Trait Implementations§
impl !RefUnwindSafe for ManagedTaskError
impl Send for ManagedTaskError
impl Sync for ManagedTaskError
impl Unpin for ManagedTaskError
impl !UnwindSafe for ManagedTaskError
Blanket Implementations§
§impl<T> Any for Twhere
T: Any + ?Sized,
impl<T> Any for Twhere
T: Any + ?Sized,
§fn type_id_compat(&self) -> TypeId
fn type_id_compat(&self) -> TypeId
TODO: once 1.33.0 is the minimum supported compiler version, remove
Any::type_id_compat and use StdAny::type_id instead.
https://github.com/rust-lang/rust/issues/27745
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
§impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
impl<F, W, T, D> Deserialize<With<T, W>, D> for Fwhere
W: DeserializeWith<F, T, D>,
D: Fallible + ?Sized,
F: ?Sized,
§fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
fn deserialize(
&self,
deserializer: &mut D
) -> Result<With<T, W>, <D as Fallible>::Error>
Deserializes using the given deserializer
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.§impl<T> Upcastable for Twhere
T: 'static + Any + Send + Sync,
impl<T> Upcastable for Twhere
T: 'static + Any + Send + Sync,
§fn upcast_any_ref(&self) -> &(dyn Any + 'static)
fn upcast_any_ref(&self) -> &(dyn Any + 'static)
upcast ref
§fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)
upcast mut ref