rocketmq_rust/
lib.rs

1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17#![feature(sync_unsafe_cell)]
18#![allow(dead_code)]
19
20mod arc_mut;
21mod blocking_queue;
22pub mod count_down_latch;
23mod netty_rust;
24pub use netty_rust::timer::Timer;
25pub mod rocketmq_tokio_lock;
26
27mod shutdown;
28pub mod task;
29
30pub mod schedule;
31
32pub use arc_mut::ArcMut;
33pub use arc_mut::SyncUnsafeCellWrapper;
34pub use arc_mut::WeakArcMut;
35pub use blocking_queue::BlockingQueue as RocketMQBlockingQueue;
36pub use count_down_latch::CountDownLatch;
37/// Re-export rocketmq main.
38pub use rocketmq::main;
39pub use rocketmq_tokio_lock::RocketMQTokioMutex;
40pub use rocketmq_tokio_lock::RocketMQTokioRwLock;
41pub use schedule::executor::ExecutorConfig;
42pub use schedule::executor::ExecutorPool;
43pub use schedule::executor::TaskExecutor;
44pub use schedule::scheduler::SchedulerConfig;
45pub use schedule::scheduler::TaskScheduler;
46pub use schedule::task::Task;
47pub use schedule::task::TaskContext;
48pub use schedule::task::TaskResult;
49pub use schedule::task::TaskStatus;
50pub use schedule::trigger::CronTrigger;
51pub use schedule::trigger::DelayTrigger;
52pub use schedule::trigger::DelayedIntervalTrigger;
53pub use schedule::trigger::IntervalTrigger;
54pub use schedule::trigger::Trigger;
55pub use shutdown::Shutdown;
56/// Re-export tokio module.
57pub use tokio as rocketmq;
58
59/// On unix platforms we want to intercept SIGINT and SIGTERM
60/// This method returns if either are signalled
61#[cfg(unix)]
62pub async fn wait_for_signal() {
63    use tokio::signal::unix::signal;
64    use tokio::signal::unix::SignalKind;
65    use tracing::info;
66    let mut term = signal(SignalKind::terminate()).expect("failed to register signal handler");
67    let mut int = signal(SignalKind::interrupt()).expect("failed to register signal handler");
68
69    tokio::select! {
70        _ = term.recv() => info!("Received SIGTERM"),
71        _ = int.recv() => info!("Received SIGINT"),
72    }
73}
74
75#[cfg(windows)]
76/// ctrl_c is the cross-platform way to intercept the equivalent of SIGINT
77/// This method returns if this occurs
78pub async fn wait_for_signal() {
79    let _ = tokio::signal::ctrl_c().await;
80}