1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Service runtime and lifecycle orchestration for Flare services.
//!
//! `flare-core-runtime` manages service tasks, dependency ordering, health
//! checks, shutdown signals, plugin hooks, metrics collection, middleware, and
//! state tracking. It is transport-neutral and is used by HTTP, gRPC, MQ, and
//! custom workers.
//!
//! # 核心特性
//!
//! - Unified service startup for HTTP, gRPC, MQ consumers, and custom tasks.
//! - Graceful shutdown with multiple signal sources and dependency ordering.
//! - Service orchestration with task dependencies, health checks, and state
//! tracking.
//! - Extensible plugin hooks, middleware chains, and custom adapters.
//!
//! # Architecture
//!
//! `flare-core-runtime` provides transport-neutral traits, configuration, and
//! orchestration primitives. Concrete adapters live in sibling crates:
//!
//! - `flare-core-transport` implements HTTP and gRPC adapters.
//! - `flare-core-messaging` implements MQ consumer adapters.
//!
//! # Example
//!
//! ```rust,no_run
//! use flare_core_runtime::{ServiceRuntime, Task, TaskResult};
//! use std::pin::Pin;
//! use std::future::Future;
//!
//! // Define a custom task.
//! struct MyTask {
//! name: String,
//! }
//!
//! impl Task for MyTask {
//! fn name(&self) -> &str {
//! &self.name
//! }
//!
//! fn run(
//! self: Box<Self>,
//! shutdown_rx: tokio::sync::oneshot::Receiver<()>,
//! ) -> Pin<Box<dyn Future<Output = TaskResult> + Send>> {
//! Box::pin(async move {
//! // Task logic.
//! Ok(())
//! })
//! }
//! }
//!
//! #[tokio::main]
//! async fn main() -> anyhow::Result<()> {
//! // Create the runtime.
//! let runtime = ServiceRuntime::new("my-service")
//! .add_task(Box::new(MyTask { name: "task-1".to_string() }));
//!
//! // Run until shutdown.
//! runtime.run().await?;
//! Ok(())
//! }
//! ```
// Module declarations.
// Re-exports
pub use RuntimeConfig;
pub use ;
pub use ;
pub use MetricsCollector;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use topological_sort;