pub struct KiteTickerManager { /* private fields */ }Expand description
High-performance multi-connection WebSocket manager for Kite ticker data
This manager creates 3 independent WebSocket connections and distributes symbols across them using round-robin allocation. Each connection has its own dedicated parser task for maximum performance.
Implementations§
Source§impl KiteTickerManager
impl KiteTickerManager
Sourcepub fn new(
api_key: String,
access_token: String,
config: KiteManagerConfig,
) -> Self
pub fn new( api_key: String, access_token: String, config: KiteManagerConfig, ) -> Self
Creates a new KiteTickerManager instance with the specified configuration
This initializes the manager with the provided API credentials and configuration,
but does not start any connections. Call start() to begin operation.
§Arguments
api_key- Your Kite Connect API keyaccess_token- Valid access token from Kite Connectconfig- Manager configuration settings
§Example
use kiteticker_async_manager::{KiteTickerManager, KiteManagerConfig, Mode};
let config = KiteManagerConfig {
max_connections: 3,
max_symbols_per_connection: 3000,
enable_dedicated_parsers: true,
default_mode: Mode::LTP,
..Default::default()
};
let manager = KiteTickerManager::new(
"your_api_key".to_string(),
"your_access_token".to_string(),
config,
);Sourcepub fn with_raw_only(self, raw: bool) -> Self
pub fn with_raw_only(self, raw: bool) -> Self
Set raw-only mode (builder uses this)
Sourcepub async fn start(&mut self) -> Result<(), String>
pub async fn start(&mut self) -> Result<(), String>
Initialize all connections 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 round-robin distribution
Sourcepub fn get_channel(
&mut self,
channel_id: ChannelId,
) -> Option<Receiver<TickerMessage>>
pub fn get_channel( &mut self, channel_id: ChannelId, ) -> Option<Receiver<TickerMessage>>
Get output channel for a specific connection
Sourcepub fn get_all_channels(&mut self) -> Vec<(ChannelId, Receiver<TickerMessage>)>
pub fn get_all_channels(&mut self) -> Vec<(ChannelId, Receiver<TickerMessage>)>
Get all output channels
Sourcepub fn get_raw_frame_channel(
&self,
channel_id: ChannelId,
) -> Option<Receiver<Bytes>>
pub fn get_raw_frame_channel( &self, channel_id: ChannelId, ) -> Option<Receiver<Bytes>>
Get a raw frame receiver (bytes::Bytes per websocket frame) for a connection. Returns None if the connection is not initialized.
Sourcepub fn get_full_raw_subscriber(
&self,
channel_id: ChannelId,
) -> Option<KiteTickerRawSubscriber184>
pub fn get_full_raw_subscriber( &self, channel_id: ChannelId, ) -> Option<KiteTickerRawSubscriber184>
Convenience: create a 184-byte Full-tick raw subscriber for a connection. Useful when operating in raw_only mode to consume only depth packets.
Sourcepub fn get_all_raw_frame_channels(&self) -> Vec<(ChannelId, Receiver<Bytes>)>
pub fn get_all_raw_frame_channels(&self) -> Vec<(ChannelId, Receiver<Bytes>)>
Convenience: get raw frame receivers for all initialized connections.
Each item is (ChannelId, broadcast::Receiver<bytes::Bytes>).
Sourcepub async fn get_stats(&self) -> Result<ManagerStats, String>
pub async fn get_stats(&self) -> Result<ManagerStats, String>
Get manager statistics
Sourcepub async fn get_health(&self) -> Result<HealthSummary, String>
pub async fn get_health(&self) -> Result<HealthSummary, String>
Get health summary
Sourcepub async fn get_processor_stats(&self) -> Vec<(ChannelId, ProcessorStats)>
pub async fn get_processor_stats(&self) -> Vec<(ChannelId, ProcessorStats)>
Get processor statistics for all channels
Sourcepub fn get_symbol_distribution(&self) -> HashMap<ChannelId, Vec<u32>>
pub fn get_symbol_distribution(&self) -> HashMap<ChannelId, Vec<u32>>
Get symbol distribution across connections
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