pub struct MultiApiKiteTickerManager { /* private fields */ }Expand description
High-performance multi-API WebSocket manager for Kite ticker data
This manager supports multiple Kite Connect API credentials, allowing you to subscribe to symbols across multiple accounts. Each API key maintains its own connection pool (up to 3 connections), and symbols can be distributed automatically or manually assigned to specific API keys.
§Example
use kiteticker_async_manager::{MultiApiKiteTickerManager, Mode};
#[tokio::main]
async fn main() -> Result<(), String> {
let mut manager = MultiApiKiteTickerManager::builder()
.add_api_key("account1", "api_key_1", "access_token_1")
.add_api_key("account2", "api_key_2", "access_token_2")
.max_connections_per_api(3)
.build();
manager.start().await?;
// Subscribe symbols (auto-distributed across API keys)
let symbols = vec![408065, 738561];
manager.subscribe_symbols(&symbols, Some(Mode::Quote)).await?;
// Or assign to specific API key
manager.subscribe_symbols_to_api("account1", &symbols, Some(Mode::LTP)).await?;
Ok(())
}Implementations§
Source§impl MultiApiKiteTickerManager
impl MultiApiKiteTickerManager
Sourcepub fn builder() -> MultiApiKiteTickerManagerBuilder
pub fn builder() -> MultiApiKiteTickerManagerBuilder
Create a builder for constructing a multi-API manager
Sourcepub async fn start(&mut self) -> Result<(), String>
pub async fn start(&mut self) -> Result<(), String>
Initialize all connections for all API keys and start the manager
Sourcepub async fn subscribe_symbols(
&mut self,
symbols: &[u32],
mode: Option<Mode>,
) -> Result<(), String>
pub async fn subscribe_symbols( &mut self, symbols: &[u32], mode: Option<Mode>, ) -> Result<(), String>
Subscribe to symbols using automatic distribution (round-robin across API keys)
Sourcepub async fn subscribe_symbols_to_api(
&mut self,
api_key_id: impl Into<ApiKeyId>,
symbols: &[u32],
mode: Option<Mode>,
) -> Result<(), String>
pub async fn subscribe_symbols_to_api( &mut self, api_key_id: impl Into<ApiKeyId>, symbols: &[u32], mode: Option<Mode>, ) -> Result<(), String>
Subscribe symbols to a specific API key
Sourcepub async fn unsubscribe_symbols(
&mut self,
symbols: &[u32],
) -> Result<(), String>
pub async fn unsubscribe_symbols( &mut self, symbols: &[u32], ) -> Result<(), String>
Unsubscribe from symbols
Sourcepub async fn change_mode(
&mut self,
symbols: &[u32],
mode: Mode,
) -> Result<(), String>
pub async fn change_mode( &mut self, symbols: &[u32], mode: Mode, ) -> Result<(), String>
Change subscription mode for existing symbols
Sourcepub fn get_unified_channel(&self) -> Receiver<(ApiKeyId, TickerMessage)>
pub fn get_unified_channel(&self) -> Receiver<(ApiKeyId, TickerMessage)>
Get the unified output channel that receives messages from all API keys
Messages are tuples of (ApiKeyId, TickerMessage)
Sourcepub fn get_channel(
&mut self,
api_key_id: impl Into<ApiKeyId>,
channel_id: ChannelId,
) -> Option<Receiver<TickerMessage>>
pub fn get_channel( &mut self, api_key_id: impl Into<ApiKeyId>, channel_id: ChannelId, ) -> Option<Receiver<TickerMessage>>
Get output channel for a specific API key and connection
Sourcepub async fn get_stats(&self) -> MultiApiStats
pub async fn get_stats(&self) -> MultiApiStats
Get aggregate statistics across all API keys
Sourcepub async fn get_api_stats(
&self,
api_key_id: impl Into<ApiKeyId>,
) -> Result<ApiKeyStats, String>
pub async fn get_api_stats( &self, api_key_id: impl Into<ApiKeyId>, ) -> Result<ApiKeyStats, String>
Get statistics for a specific API key
Sourcepub fn get_symbol_distribution(
&self,
) -> HashMap<ApiKeyId, HashMap<usize, Vec<u32>>>
pub fn get_symbol_distribution( &self, ) -> HashMap<ApiKeyId, HashMap<usize, Vec<u32>>>
Get symbol distribution across all API keys and connections
Sourcepub fn get_api_keys(&self) -> Vec<ApiKeyId>
pub fn get_api_keys(&self) -> Vec<ApiKeyId>
Get list of all configured API key IDs