Skip to main content

lwleen_rpc/
lib.rs

1//! 🛸 `信令路由`(RPC)
2//! # 介绍
3//! 主页 [Homepage](https://docs.qq.com/aio/p/sc3gu8sft77pu68)  
4//! crates官方仓库  [https://crates.io/crates/lwleen](https://crates.io/crates/lwleen)  
5//! 
6//! RPC 是 Remote Procedure Call(远程过程调用),用于组件间数据通信 
7//! 
8//! # 信令路由
9//! 可扩展,自定义服务器  
10//! [https://docs.rs/crate/lwleen-rpc/latest/source/src/mod_rpc.rs](https://docs.rs/crate/lwleen-rpc/latest/source/src/mod_rpc.rs)    
11
12#![allow(non_snake_case)]
13#![allow(non_camel_case_types)]
14#![allow(unused_imports)]
15// #![allow(dead_code)]
16
17
18#[macro_use]
19pub mod macros;          // 宏     顶层直接调用宏
20
21// 模块
22pub mod mod_rpc;
23pub mod mod_pool;
24pub mod mod_state;
25pub mod mod_timer;
26pub mod mod_tool;
27pub mod mod_demo;
28
29
30
31// 重新导出常用模块
32pub use anyhow;
33pub use serde;
34pub use serde_json;
35pub use futures;
36pub use futures_lite;          // pub use parking;
37pub use async_channel;
38pub use crossbeam_channel;
39pub use chrono;
40pub use uuid;
41pub use lwleen_macro;
42// pub use smol;
43
44
45
46
47
48/// prelude  `预接口`
49/// > `⚡️信令路由`  `💖常用库`  `🌷常用的方法` 
50/// 
51/// ```no_run
52/// 下面是 lwleen_rpc 导出的💖常用库
53/// use anyhow
54/// use serde
55/// use serde_json
56/// use lwleen_rpc::futures
57/// use futures_lite
58/// use async_channel
59/// use crossbeam_channel
60/// use chrono
61/// use uuid
62/// use lwleen_macro
63/// ```
64pub mod prelude{
65    
66    pub use std::{ 
67        // std::fmt::{Display, Debug},
68        // std::time::Instant, 
69        borrow::Cow,
70        sync::{ Arc, atomic::{ AtomicBool,AtomicUsize,AtomicU64,Ordering}},    // Mutex, RwLock
71        boxed::Box, pin::Pin, // pin 宏
72        any::{ Any },
73        cell::{ Cell, RefCell },                                               //Cell<Copy或Default类型>     RefCell<任意复杂类型> 提供内部可变性   无须 mut 通过不可变引用修改数据  
74        collections::{HashMap,HashSet},
75    };
76    pub use dashmap::{ DashMap,DashSet};                                    //💖自带锁管理, 但有线程Sync限制, HashMap更自由💖
77    // pub use indexmap::{ IndexMap,IndexSet};
78
79
80    pub use anyhow::{ Error as anyhow_Error, Result as anyhow_Result, anyhow as anyhow_err, Ok as anyhow_Ok };
81    pub use once_cell::sync::{OnceCell, Lazy};                              // 替代  std::sync::OnceLock 自定义延迟初始化   lazy_static 延迟初始化
82    pub use parking_lot::{ Mutex, RwLock, Condvar, Once};                   //1.5x faster than std::sync::Mutex when uncontended, and up to 5x faster when contended from multiple threads
83    pub use serde::{ Serialize, Deserialize };
84    pub use serde_json::{ json, Value, from_value, from_str, from_slice };
85    pub use futures::{ join, try_join, select, channel::oneshot };    // join!()  必须等待所有完成    try_join!()  有一个错误,立即结束  select!()  任何一个 Future 结束后,都可以立即被处理结果
86
87    pub use async_lock::{ Mutex as async_Mutex, RwLock as async_RwLock };
88    // pub use flume::{
89    //     Receiver as flume_Receiver, Sender as flume_Sender,
90    //     bounded as flume_bounded, unbounded as flume_unbounded,
91    // };
92    pub use async_channel::{
93        Receiver as async_Receiver,Sender as async_Sender,                      // force_send   send_blocking   recv_blocking 
94        bounded as async_bounded, unbounded as async_unbounded,
95    };
96    /// - 仓库 <https://crates.io/crates/futures-lite>
97    /// - 代码 <https://docs.rs/futures-lite/latest/src/futures_lite/future.rs.html#53-102>
98    pub use futures_lite::future::block_on as block_on_lite;
99    // pub use async_io;                                                        //后台有个服务线程   `async-io`   // 不支持wasm32
100    pub use futures_timer::Delay;                                               //后台有个服务线程   src/native/global.rs ::HelperThread
101
102
103
104    pub use lwleen_macro::{ gen_特征_derive, EnumDisplay  };
105    pub use crate::{
106        cfg_if, cfg_多行特性, 
107        match取出,
108        impl信令特征,
109        core发布信令任务,
110        anyhow_Ok信令, anyhow_Err信令,
111        join_path,
112    };
113    pub use crate::mod_tool::{
114        全局_启动时间,全局_CPU数量,
115        TIME时间, 线程同步控制,
116        原子ID, 原子ID对象,
117    };
118    pub use crate::mod_rpc::{
119        rpc类型,
120        信令路由,
121        信令任务Builder, 信令任务,
122        Box信令特征, 信令特征,                 // Send 是所有权可以转移线程  +  Sync 是可以多线程访问
123        信令异步执行函数, 
124        信令ID, 信令发送包,
125        rpc路由状态, 
126        定时器,
127    };
128    pub use crate::mod_pool::{  ThreadPool, Builder as ThreadPool_Builder };
129    pub use crate::mod_state::{ StateManager, State  };
130    pub use crate::mod_timer::{ Timeout限时特征 };
131}