Skip to content

Commit 20be00e

Browse files
committed
restore section for multiple streams + normalize
1 parent 3589d81 commit 20be00e

File tree

3 files changed

+22
-50
lines changed

3 files changed

+22
-50
lines changed

src/content/data-streams/tutorials/go-sdk-stream.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,16 @@ When HA mode is enabled, the SDK maintains at least 2 concurrent connections to
390390

391391
See more details about HA mode in the [SDK Reference](/data-streams/reference/data-streams-api/go-sdk#high-availability-ha-mode).
392392

393+
### Subscribing to multiple streams
394+
395+
You can subscribe to multiple streams by providing additional stream IDs as command-line arguments:
396+
397+
```bash
398+
go run stream.go 0x000359843a543ee2fe414dc14c7e7920ef10f4372990b79d6361cdc0dd1ba782 0x00036fe43f87884450b4c7e093cd5ed99cac6640d8c2000e6afc02c8838d0265
399+
```
400+
401+
This will subscribe to both ETH/USD and BTC/USD streams.
402+
393403
### Payload for onchain verification
394404

395405
In this tutorial, you logged and decoded the `full_report` payloads to extract the report data. However, in a production environment, you should verify the data to ensure its integrity and authenticity.

src/content/data-streams/tutorials/rust-sdk-stream.mdx

Lines changed: 2 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,8 @@ The example above demonstrates streaming data from a single crypto stream. For p
329329

330330
When HA mode is enabled and multiple WebSocket origins are provided, the Stream will maintain concurrent connections to different instances. This ensures high availability, fault tolerance, and minimizes the risk of report gaps.
331331

332+
#### Subscribing to multiple streams
333+
332334
You can subscribe to multiple streams by providing additional stream IDs as command-line arguments:
333335

334336
```bash
@@ -365,56 +367,6 @@ For descriptions and data types of other report schemas, see the [Report Schema
365367

366368
High Availability (HA) mode creates multiple WebSocket connections to different origin endpoints for improved reliability. When enabled, the SDK automatically handles failover, deduplicates reports, and provides connection-level metrics.
367369

368-
#### Enabling HA mode
369-
370-
To enable HA mode in your streaming application, make these changes to the basic example:
371-
372-
1. Add multiple WebSocket endpoints and enable HA mode in the client configuration. You also must use a mainnet endpoint, as HA mode is not currently supported on testnet.
373-
374-
```rust
375-
use chainlink_data_streams_sdk::config::{Config, WebSocketHighAvailability};
376-
377-
let config = Config::new(
378-
api_key,
379-
api_secret,
380-
"https://api.dataengine.chain.link".to_string(), // Mainnet endpoint
381-
"wss://ws1.dataengine.chain.link,wss://ws2.dataengine.chain.link".to_string(), // Multiple WebSocket endpoints
382-
)
383-
.with_ws_ha(WebSocketHighAvailability::Enabled) // Enable High Availability mode
384-
.with_ws_max_reconnect(10) // Optional: Increase max reconnection attempts
385-
.build()?;
386-
```
387-
388-
2. Optionally, monitor HA metrics using the existing `get_stats()` calls in your report handler:
389-
390-
```rust
391-
// In your report processing loop
392-
match stream.read().await {
393-
Ok(report) => {
394-
// ... your report processing logic
395-
396-
// HA-specific metrics
397-
let stats = stream.get_stats();
398-
info!(
399-
"📊 Stats: {} reports | {}/{} connections",
400-
stats.accepted, stats.active_connections, stats.configured_connections
401-
);
402-
info!("Reconnects: {} partial, {} full", stats.partial_reconnects, stats.full_reconnects);
403-
404-
// Check deduplication (important for HA mode)
405-
if stats.total_received > 0 {
406-
let dedup_rate = (stats.deduplicated as f64 / stats.total_received as f64) * 100.0;
407-
info!("Deduplication rate: {:.1}%", dedup_rate);
408-
}
409-
}
410-
Err(e) => {
411-
warn!("Error reading from stream: {}", e);
412-
}
413-
}
414-
```
415-
416-
See more details about HA mode in the [SDK Reference](/rust-sdk#websocket-features).
417-
418370
### Payload for onchain verification
419371

420372
In this tutorial, you logged and decoded the `full_report` payloads to extract the report data. However, in a production environment, you should verify the data to ensure its integrity and authenticity.

src/content/data-streams/tutorials/ts-sdk-stream.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,16 @@ The optional `connectionStatusCallback` can be used to integrate with external m
408408
409409
See more details about HA mode in the [SDK Reference](/ts-sdk#high-availability-mode).
410410
411+
### Subscribing to multiple streams
412+
413+
You can subscribe to multiple streams by providing additional stream IDs as command-line arguments:
414+
415+
```bash
416+
npx tsx stream.ts 0x000359843a543ee2fe414dc14c7e7920ef10f4372990b79d6361cdc0dd1ba782,0x00036fe43f87884450b4c7e093cd5ed99cac6640d8c2000e6afc02c8838d0265
417+
```
418+
419+
This will subscribe to both ETH/USD and BTC/USD streams.
420+
411421
### Payload for onchain verification
412422
413423
In this tutorial, you logged and decoded the `full_report` payloads to extract the report data. However, in a production environment, you should verify the data to ensure its integrity and authenticity.

0 commit comments

Comments
 (0)