Skip to content

Commit c15f283

Browse files
committed
fix: formatting, example
1 parent 9474cfc commit c15f283

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

lazer/sdk/rust/sdk/examples/subscribe_price_feeds.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use pyth_lazer_sdk::LazerClient;
1010
async fn main() -> anyhow::Result<()> {
1111
// Create and start the client
1212
let mut client = LazerClient::new(
13-
"wss://hermes.pyth.network",
14-
"YOUR_ACCESS_TOKEN".to_string(),
13+
"wss://pyth-lazer.dourolabs.app/v1/stream",
14+
"YOUR_ACCESS_TOKEN",
1515
)?;
1616
let mut stream = client.start().await?;
1717

@@ -36,12 +36,12 @@ async fn main() -> anyhow::Result<()> {
3636

3737
println!("Subscribed to BTC/USD price feed. Waiting for updates...");
3838

39-
// Process the first 5 updates
39+
// Process the first 100 updates
4040
let mut count = 0;
4141
while let Some(msg) = stream.next().await {
4242
println!("Received update: {:?}", msg?);
4343
count += 1;
44-
if count >= 5 {
44+
if count >= 100 {
4545
break;
4646
}
4747
}

lazer/sdk/rust/sdk/src/lib.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,14 @@ pub enum BinaryResponse {
5757
pub struct LazerClient {
5858
endpoint: Url,
5959
access_token: String,
60-
ws_sender: Option<futures_util::stream::SplitSink<
61-
tokio_tungstenite::WebSocketStream<
62-
tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>,
60+
ws_sender: Option<
61+
futures_util::stream::SplitSink<
62+
tokio_tungstenite::WebSocketStream<
63+
tokio_tungstenite::MaybeTlsStream<tokio::net::TcpStream>,
64+
>,
65+
Message,
6366
>,
64-
Message,
65-
>>,
67+
>,
6668
}
6769

6870
impl LazerClient {
@@ -74,8 +76,9 @@ impl LazerClient {
7476
///
7577
/// # Returns
7678
/// Returns a new client instance (not yet connected)
77-
pub fn new(endpoint: &str, access_token: String) -> Result<Self> {
79+
pub fn new(endpoint: &str, access_token: &str) -> Result<Self> {
7880
let endpoint = Url::parse(endpoint)?;
81+
let access_token = access_token.to_string();
7982
Ok(Self {
8083
endpoint,
8184
access_token,
@@ -89,8 +92,9 @@ impl LazerClient {
8992
/// Returns a stream of responses from the server
9093
pub async fn start(&mut self) -> Result<impl futures_util::Stream<Item = Result<Response>>> {
9194
let url = self.endpoint.clone();
92-
let mut request = tokio_tungstenite::tungstenite::client::IntoClientRequest::into_client_request(url)?;
93-
95+
let mut request =
96+
tokio_tungstenite::tungstenite::client::IntoClientRequest::into_client_request(url)?;
97+
9498
request.headers_mut().insert(
9599
"Authorization",
96100
format!("Bearer {}", self.access_token).parse().unwrap(),
@@ -166,7 +170,7 @@ impl LazerClient {
166170
}
167171
});
168172

169-
Ok((client, response_stream))
173+
Ok(response_stream)
170174
}
171175

172176
/// Subscribes to price feed updates

0 commit comments

Comments
 (0)