|
|
@@ -22,8 +22,6 @@ lazy_static! {
|
|
|
}
|
|
|
|
|
|
pub async fn run_listener(is_shutdown_arc: Arc<AtomicBool>) {
|
|
|
- let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
|
|
|
- let write_tx_am = Arc::new(Mutex::new(write_tx));
|
|
|
let name = "bitget_usdt_swap_listener";
|
|
|
// 订阅所有币种
|
|
|
let login = BTreeMap::new();
|
|
|
@@ -36,19 +34,29 @@ pub async fn run_listener(is_shutdown_arc: Arc<AtomicBool>) {
|
|
|
symbols.push(info["symbol"].as_str().unwrap().to_string())
|
|
|
}
|
|
|
}
|
|
|
- info!(?symbols);
|
|
|
|
|
|
- tokio::spawn(async move {
|
|
|
- let mut ws = BitgetSwapWs::new_with_tag(name.to_string(), false, None, BitgetSwapWsType::Public);
|
|
|
+ // 将 symbols 分成每份20个元素的小块
|
|
|
+ for chunk in symbols.chunks(20) {
|
|
|
+ let (write_tx, write_rx) = futures_channel::mpsc::unbounded();
|
|
|
+ let write_tx_am = Arc::new(Mutex::new(write_tx));
|
|
|
+
|
|
|
+ let symbols_chunk = chunk.iter().cloned().collect::<Vec<String>>();
|
|
|
+ let ws_name = name.to_string();
|
|
|
+ let write_tx_clone = Arc::clone(&write_tx_am);
|
|
|
+ let is_shutdown_clone = Arc::clone(&is_shutdown_arc);
|
|
|
+
|
|
|
+ tokio::spawn(async move {
|
|
|
+ let mut ws = BitgetSwapWs::new_with_tag(ws_name, false, None, BitgetSwapWsType::Public);
|
|
|
ws.set_subscribe(vec![
|
|
|
BitgetSwapSubscribeType::PuTrade,
|
|
|
- BitgetSwapSubscribeType::PuCandle1m
|
|
|
+ BitgetSwapSubscribeType::PuCandle1m,
|
|
|
]);
|
|
|
|
|
|
- // 建立链接
|
|
|
- ws.set_symbols(symbols);
|
|
|
- ws.ws_connect_async(is_shutdown_arc, data_listener, &write_tx_am, write_rx).await.unwrap();
|
|
|
- });
|
|
|
+ // 建立链接
|
|
|
+ ws.set_symbols(symbols_chunk);
|
|
|
+ ws.ws_connect_async(is_shutdown_clone, data_listener, &write_tx_clone, write_rx).await.unwrap();
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 读取数据
|
|
|
@@ -76,7 +84,7 @@ pub async fn data_listener(response: ResponseData) {
|
|
|
},
|
|
|
// k线数据
|
|
|
"candle1m" => {
|
|
|
- // let records = ExchangeStructHandler::records_handle(ExchangeEnum::BitgetSwap, &response);
|
|
|
+ let _records = ExchangeStructHandler::records_handle(ExchangeEnum::BitgetSwap, &response);
|
|
|
//
|
|
|
// for record in records.iter() {
|
|
|
// info!(?record);
|