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
/// Manage multiple running services. A ProcessManager collects impl of `Runnable`
/// and takes over the runtime management like starting, stopping (graceful or in
/// failure) of services.
///
/// ```rust
/// use processmanager::*;
/// use std::sync::Arc;
///
/// #[tokio::main]
/// async fn main() {
///
/// #[derive(Default)]
/// struct ExampleController {
/// runtime_guard: RuntimeGuard,
/// }
///
/// impl Runnable for ExampleController {
/// fn process_start(&self) -> ProcFuture<'_> {
/// Box::pin(async{
/// let ticker = self.runtime_guard.runtime_ticker().await;
///
/// // This can be any type of future like an async streams
/// let mut interval = tokio::time::interval(tokio::time::Duration::from_secs(1));
///
/// loop {
/// match ticker.tick(interval.tick()).await {
/// ProcessOperation::Next(_) => println!("work"),
/// ProcessOperation::Control(RuntimeControlMessage::Shutdown) => {
/// println!("shutdown");
/// break
/// },
/// ProcessOperation::Control(RuntimeControlMessage::Reload) => println!("trigger relead"),
/// ProcessOperation::Control(RuntimeControlMessage::Custom(_)) => println!("trigger custom action"),
/// ProcessOperation::Control(_) => unimplemented!(),
/// }
/// }
///
/// Ok(())
/// })
/// }
///
/// fn process_handle(&self) -> Arc<dyn ProcessControlHandler> {
/// self.runtime_guard.handle()
/// }
/// }
///
/// let manager = ProcessManagerBuilder::default()
/// .pre_insert(ExampleController::default())
/// .build();
///
/// let handle = manager.process_handle();
///
/// // start all processes
/// let _ = tokio::spawn(async move {
/// manager.process_start().await.expect("service start failed");
/// });
///
/// // Shutdown waits for all services to shut down gracefully.
/// handle.shutdown().await;
/// }
/// ```
///
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;