You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/data-streams/tutorials/go-sdk-stream.mdx
+26-36Lines changed: 26 additions & 36 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -327,53 +327,49 @@ The decoded report details include:
327
327
328
328
For descriptions and data types of other report schemas, see the [Report Schema Overview](/data-streams/reference/report-schema-overview).
329
329
330
+
### Subscribing to multiple streams
331
+
332
+
You can subscribe to multiple streams by providing additional stream IDs as command-line arguments:
333
+
334
+
```bash
335
+
go run stream.go 0x000359843a543ee2fe414dc14c7e7920ef10f4372990b79d6361cdc0dd1ba782 0x00036fe43f87884450b4c7e093cd5ed99cac6640d8c2000e6afc02c8838d0265
336
+
```
337
+
338
+
This will subscribe to both ETH/USD and BTC/USD streams.
339
+
330
340
### High Availability (HA) mode
331
341
332
342
<Asidetype="note"title="Mainnet only">
333
343
HA mode is only available on mainnet endpoints, not testnet.
334
344
</Aside>
335
345
336
-
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.
346
+
The example above demonstrates streaming data from a single crypto stream. For production environments, especially when subscribing to multiple streams, it's recommended to enable [High Availability (HA) mode](/data-streams/reference/data-streams-api/go-sdk#high-availability-ha-mode).
347
+
348
+
High Availability (HA) mode creates multiple WebSocket connections to different origin endpoints for improved reliability. When HA mode is enabled, the Stream will maintain at least 2 concurrent connections to different instances to ensure high availability, fault tolerance and minimize the risk of report gaps.
337
349
338
350
#### Enabling HA mode
339
351
340
352
To enable HA mode in your streaming application, make these changes to the basic example:
341
353
342
-
1. Add HA mode to the client configuration and use a mainnet endpoint, as HA mode is not currently supported on testnet:
343
-
344
354
```go
355
+
// ... existing code ...
356
+
357
+
// Enable HA mode with mainnet endpoint
345
358
cfg:= streams.Config{
346
359
ApiKey: os.Getenv("API_KEY"),
347
360
ApiSecret: os.Getenv("API_SECRET"),
348
361
WsURL: "wss://ws.dataengine.chain.link", // Use mainnet endpoint for HA mode
349
362
WsHA: true, // Enable High Availability mode
350
363
Logger: streams.LogPrintf,
351
364
}
352
-
```
353
-
354
-
2. Monitor HA metrics using the existing `Stats()` calls in your report handler:
When HA mode is enabled, the SDK maintains at least 2 concurrent connections to different instances to ensure high availability, fault tolerance, and minimize the risk of report gaps.
390
-
391
-
See more details about HA mode in the [SDK Reference](/data-streams/reference/data-streams-api/go-sdk#high-availability-ha-mode).
392
383
393
-
### Subscribing to multiple streams
384
+
// ... existing code ...
385
+
```
394
386
395
-
You can subscribe to multiple streams by providing additional stream IDs as command-line arguments:
387
+
When `WsHA` is `true`, the SDK automatically discovers multiple origin endpoints behind the single URL and establishes separate connections to each origin. You also must use a mainnet endpoint, as HA mode is not currently supported on testnet.
396
388
397
-
```bash
398
-
go run stream.go 0x000359843a543ee2fe414dc14c7e7920ef10f4372990b79d6361cdc0dd1ba782 0x00036fe43f87884450b4c7e093cd5ed99cac6640d8c2000e6afc02c8838d0265
399
-
```
389
+
The optional `StreamWithStatusCallback` can be used to monitor individual connection status. The SDK already provides comprehensive connection logs through `stream.Stats().String()`, so this callback is primarily useful for custom alerting or connection monitoring.
400
390
401
-
This will subscribe to both ETH/USD and BTC/USD streams.
391
+
See more details about HA mode in the [SDK Reference](/data-streams/reference/data-streams-api/go-sdk#high-availability-ha-mode).
Copy file name to clipboardExpand all lines: src/content/data-streams/tutorials/rust-sdk-stream.mdx
+35-27Lines changed: 35 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -310,25 +310,6 @@ In this tutorial, you'll learn how to use the [Data Streams SDK](/data-streams/r
310
310
311
311
[Learn more about the decoded report details](#decoded-report-details).
312
312
313
-
### High Availability (HA) Mode
314
-
315
-
The example above demonstrates streaming data from a single crypto stream. For production environments, especially when subscribing to multiple streams, it's recommended to enable [High Availability (HA) mode](https://github.com/smartcontractkit/data-streams-sdk/blob/main/rust/docs/examples/wss_multiple.md). This can be achieved by:
316
-
317
-
1. Adding multiple WebSocket endpoints in the configuration:
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.
331
-
332
313
#### Subscribing to multiple streams
333
314
334
315
You can subscribe to multiple streams by providing additional stream IDs as command-line arguments:
@@ -341,6 +322,41 @@ cargo run -- \
341
322
342
323
This will subscribe to both ETH/USD and BTC/USD streams.
343
324
325
+
### High Availability (HA) mode
326
+
327
+
<Asidetype="note"title="Mainnet only">
328
+
HA mode is only available on mainnet endpoints, not testnet.
329
+
</Aside>
330
+
331
+
The example above demonstrates streaming data from a single crypto stream. For production environments, especially when subscribing to multiple streams, it's recommended to enable [High Availability (HA) mode](/data-streams/reference/data-streams-api/rust-sdk#high-availability-mode).
332
+
333
+
High Availability (HA) mode creates multiple WebSocket connections to different origin endpoints for improved reliability. When HA mode is enabled, the Stream will maintain at least 2 concurrent connections to different instances to ensure high availability, fault tolerance and minimize the risk of report gaps.
334
+
335
+
#### Enabling HA mode
336
+
337
+
To enable HA mode in your streaming application, make these changes to the basic example. You also must use a mainnet endpoint, as HA mode is not currently supported on testnet.
.with_ws_ha(WebSocketHighAvailability::Enabled) // Enable WebSocket High Availability Mode
352
+
.build()?;
353
+
354
+
355
+
// ... existing code ...
356
+
```
357
+
358
+
See more details about HA mode in the [SDK Reference](/data-streams/reference/data-streams-api/rust-sdk#high-availability-mode).
359
+
344
360
### Decoded report details
345
361
346
362
The decoded report details include:
@@ -359,14 +375,6 @@ The decoded report details include:
359
375
360
376
For descriptions and data types of other report schemas, see the [Report Schema Overview](/data-streams/reference/report-schema-overview).
361
377
362
-
### High Availability (HA) mode
363
-
364
-
<Asidetype="note"title="Mainnet only">
365
-
HA mode is only available on mainnet endpoints, not testnet.
366
-
</Aside>
367
-
368
-
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.
369
-
370
378
### Payload for onchain verification
371
379
372
380
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.
This will subscribe to both ETH/USD and BTC/USD streams.
358
+
349
359
### High Availability (HA) mode
350
360
351
361
<Aside type="note" title="Mainnet only">
352
362
HA mode is only available on mainnet endpoints, not testnet.
353
363
</Aside>
354
364
355
-
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.
365
+
The example above demonstrates streaming data from a single crypto stream. For production environments, especially when subscribing to multiple streams, it's recommended to enable [High Availability (HA) mode](/data-streams/reference/data-streams-api/ts-sdk#high-availability-mode).
366
+
367
+
High Availability (HA) mode creates multiple WebSocket connections to different origin endpoints for improved reliability. When HA mode is enabled, the Stream will maintain at least 2 concurrent connections to different instances to ensure high availability, fault tolerance and minimize the risk of report gaps.
356
368
357
369
#### Enabling HA mode
358
370
359
371
To enable HA mode in your streaming application, make these changes to the basic example:
360
372
361
-
1. Add `haMode: true` to the client configuration. You also must use a mainnet endpoint, as HA mode is not currently supported on testnet.
When `haMode` is `true`, the SDK automatically discovers multiple origin endpoints behind the single URL and establishes separate connections to each origin.
404
+
When `haMode` is `true`, the SDK automatically discovers multiple origin endpoints behind the single URL and establishes separate connections to each origin. You also must use a mainnet endpoint, as HA mode is not currently supported on testnet.
406
405
407
406
The optional `connectionStatusCallback` can be used to integrate with external monitoring systems. The SDK already provides comprehensive connection logs, so this callback is primarily useful for custom alerting or metrics collection.
408
407
409
-
See more details about HA mode in the [SDK Reference](/ts-sdk#high-availability-mode).
410
-
411
-
### Subscribing to multiple streams
412
-
413
-
You can subscribe to multiple streams by providing additional stream IDs as command-line arguments:
0 commit comments