Expand description
§Pyth Lazer Client
This module provides a high-level client for connecting to Pyth Lazer data streams. The client maintains multiple WebSocket connections for redundancy and provides automatic deduplication of messages.
§Features
- Multiple redundant WebSocket connections
- Automatic message deduplication
- Exponential backoff for reconnections
- Configurable timeouts and channel capacities
- Builder pattern for easy configuration
§Basic Usage
ⓘ
use pyth_lazer_client::PythLazerClientBuilder;
use pyth_lazer_protocol::subscription::SubscribeRequest;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let mut client = PythLazerClientBuilder::new("your_access_token".to_string())
.with_num_connections(2)
.build()?;
let mut receiver = client.start().await?;
// Subscribe to price feeds
let subscribe_request = SubscribeRequest {
// ... configure subscription
};
client.subscribe(subscribe_request).await?;
// Process incoming messages
while let Some(response) = receiver.recv().await {
println!("Received: {:?}", response);
}
Ok(())
}
Structs§
- Pyth
Lazer Client - A high-performance client for connecting to Pyth Lazer data streams.
- Pyth
Lazer Client Builder - A builder for creating
PythLazerClient
instances with customizable configuration.