1#![deny(clippy::disallowed_methods)]
21
22use std::fmt;
31
32mod quickwit_common;
33
34use crate::quickwit_common::proto::{ServiceError, ServiceErrorCode};
35use tokio::time::Duration;
36mod actor;
37mod actor_context;
38mod actor_handle;
39mod actor_state;
40#[doc(hidden)]
41pub mod channel_with_priority;
42mod command;
43mod envelope;
44mod mailbox;
45mod observation;
46mod registry;
47pub(crate) mod scheduler;
48mod spawn_builder;
49mod supervisor;
50
51pub use scheduler::{start_scheduler, SchedulerClient};
52
53#[cfg(test)]
54pub(crate) mod tests;
55mod universe;
56
57use crate::quickwit_common::KillSwitch;
58pub use actor::{Actor, ActorExitStatus, DeferableReplyHandler, Handler};
59pub use actor_handle::{ActorHandle, Health, Healthz, Supervisable};
60pub use command::Command;
61pub use observation::{Observation, ObservationType};
62pub use spawn_builder::SpawnContext;
63use thiserror::Error;
64pub use universe::Universe;
65
66pub use self::actor_context::ActorContext;
67pub use self::actor_state::ActorState;
68pub use self::channel_with_priority::{QueueCapacity, RecvError, SendError, TrySendError};
69pub use self::mailbox::{Inbox, Mailbox};
70pub use self::registry::ActorObservation;
71pub use self::supervisor::{Supervisor, SupervisorState};
72
73pub const HEARTBEAT: Duration = if cfg!(any(test, feature = "testsuite")) {
79 Duration::from_millis(500)
85} else {
86 Duration::from_secs(3)
87};
88
89const OBSERVE_TIMEOUT: Duration = Duration::from_secs(3);
93
94#[derive(Error, Debug)]
96pub enum AskError<E: fmt::Debug> {
97 #[error("Message could not be delivered")]
98 MessageNotDelivered,
99 #[error("Error while the message was being processed.")]
100 ProcessMessageError,
101 #[error("The handler returned an error: `{0:?}`.")]
102 ErrorReply(#[from] E),
103}
104
105impl<E: fmt::Debug + ServiceError> ServiceError for AskError<E> {
106 fn status_code(&self) -> ServiceErrorCode {
107 match self {
108 AskError::MessageNotDelivered => ServiceErrorCode::Internal,
109 AskError::ProcessMessageError => ServiceErrorCode::Internal,
110 AskError::ErrorReply(err) => err.status_code(),
111 }
112 }
113}