diff --git a/src/content/data-streams/llms-full.txt b/src/content/data-streams/llms-full.txt index 5fd74f10adc..01b9789f603 100644 --- a/src/content/data-streams/llms-full.txt +++ b/src/content/data-streams/llms-full.txt @@ -4555,11 +4555,27 @@ Security best practices: ### High Availability Mode +The Data Streams SDK supports High Availability mode for WebSocket connections. When enabled with `WebSocketHighAvailability::Enabled`, the SDK maintains concurrent connections to different instances to ensure high availability, fault tolerance, and minimize the risk of report gaps. + +#### HA Mode Behavior + +When high availability mode is enabled: + +- The client queries the server for available origins using the `X-Cll-Available-Origins` header +- Multiple WebSocket connections are established to different server instances +- Reports are deduplicated when received across connections +- Partial reconnects occur when some connections fail while others remain active +- Full reconnects occur when all connections fail + +#### HA Configuration + +Pass a single WebSocket URL. When HA mode is enabled, the SDK discovers additional origin endpoints behind that URL and opens a connection to each origin. + ```rust use chainlink_data_streams_sdk::config::{Config, WebSocketHighAvailability}; -let ws_urls = "wss://ws1.dataengine.chain.link,wss://ws2.dataengine.chain.link"; -let config = Config::new(api_key, api_secret, rest_url, ws_urls) +let ws_url = "wss://ws.dataengine.chain.link"; +let config = Config::new(api_key, api_secret, rest_url, ws_url) // Enable WebSocket HA mode .with_ws_ha(WebSocketHighAvailability::Enabled) // Increase the max reconnection attempts (optional, default is 5) @@ -4567,7 +4583,9 @@ let config = Config::new(api_key, api_secret, rest_url, ws_urls) .build()?; ``` -- Multiple WebSocket endpoints +**Note:** High Availability mode is only available on mainnet endpoints, not testnet. + +- Automatic origin discovery from a single WebSocket URL - Automatic failover on connection loss - Parallel connections to reduce gaps in data @@ -4576,7 +4594,7 @@ let config = Config::new(api_key, api_secret, rest_url, ws_urls) The SDK allows you to: - Set `ws_max_reconnect`: The maximum number of reconnection attempts (default: 5) -- Enable HA for multiple WebSocket endpoints +- Enable HA for automatic multi-origin WebSocket connections - Optional `insecure_skip_verify` for TLS Example: @@ -4584,9 +4602,9 @@ Example: ```rust use chainlink_data_streams_sdk::config::{Config, InsecureSkipVerify, WebSocketHighAvailability}; -let ws_urls = "wss://ws.testnet-dataengine.chain.link"; +let ws_url = "wss://ws.testnet-dataengine.chain.link"; -let config = Config::new(api_key, api_secret, rest_url, ws_urls) +let config = Config::new(api_key, api_secret, rest_url, ws_url) .with_ws_ha(WebSocketHighAvailability::Enabled) .with_ws_max_reconnect(5) .with_insecure_skip_verify(InsecureSkipVerify::Enabled) @@ -4638,7 +4656,7 @@ The [SDK repository](https://github.com/smartcontractkit/data-streams-sdk/blob/m - Fetching a single report, bulk reports, or paginated reports - Compressing report data - Simple WebSocket streaming -- Multiple WebSocket endpoints (HA) +- WebSocket streaming with HA mode ## Performance Considerations @@ -4674,14 +4692,14 @@ pub struct ConfigBuilder { - Purpose: Enables or disables HA mode for WebSocket streaming. - Values: - - `WebSocketHighAvailability::Enabled`: Maintains multiple WebSocket connections to different endpoints simultaneously. + - `WebSocketHighAvailability::Enabled`: Discovers available origins from the configured WebSocket URL and maintains multiple connections simultaneously. - `WebSocketHighAvailability::Disabled`: Maintains a single connection. - Default: `Disabled`. - Example Use Case: ```rust - // When you want uninterrupted streaming even if one server goes down: - let config = Config::new(api_key, api_secret, rest_url, "wss://ws1,...,wss://wsN") + // When you want uninterrupted streaming even if one origin goes down: + let config = Config::new(api_key, api_secret, rest_url, "wss://ws.dataengine.chain.link") .with_ws_ha(WebSocketHighAvailability::Enabled) .build()?; ``` @@ -8953,7 +8971,7 @@ let config = Config::new( api_key, api_secret, "https://api.dataengine.chain.link".to_string(), // Mainnet endpoint - "wss://ws.dataengine.chain.link,wss://ws.dataengine.chain.link".to_string(), // Multiple WebSocket endpoints + "wss://ws.dataengine.chain.link".to_string(), // Mainnet WebSocket endpoint ) .with_ws_ha(WebSocketHighAvailability::Enabled) // Enable WebSocket High Availability Mode .build()?; @@ -8962,6 +8980,8 @@ let config = Config::new( // ... existing code ... ``` +When `WebSocketHighAvailability::Enabled` is set, the SDK automatically discovers multiple origin endpoints behind the single URL and establishes separate connections to each origin. + See more details about HA mode in the [SDK Reference](/data-streams/reference/data-streams-api/rust-sdk#high-availability-mode). ### Decoded report details diff --git a/src/content/data-streams/reference/data-streams-api/rust-sdk.mdx b/src/content/data-streams/reference/data-streams-api/rust-sdk.mdx index 6b6194c5c56..b96d4c9928a 100644 --- a/src/content/data-streams/reference/data-streams-api/rust-sdk.mdx +++ b/src/content/data-streams/reference/data-streams-api/rust-sdk.mdx @@ -149,11 +149,27 @@ Security best practices: ### High Availability Mode +The Data Streams SDK supports High Availability mode for WebSocket connections. When enabled with `WebSocketHighAvailability::Enabled`, the SDK maintains concurrent connections to different instances to ensure high availability, fault tolerance, and minimize the risk of report gaps. + +#### HA Mode Behavior + +When high availability mode is enabled: + +- The client queries the server for available origins using the `X-Cll-Available-Origins` header +- Multiple WebSocket connections are established to different server instances +- Reports are deduplicated when received across connections +- Partial reconnects occur when some connections fail while others remain active +- Full reconnects occur when all connections fail + +#### HA Configuration + +Pass a single WebSocket URL. When HA mode is enabled, the SDK discovers additional origin endpoints behind that URL and opens a connection to each origin. + ```rust use chainlink_data_streams_sdk::config::{Config, WebSocketHighAvailability}; -let ws_urls = "wss://ws1.dataengine.chain.link,wss://ws2.dataengine.chain.link"; -let config = Config::new(api_key, api_secret, rest_url, ws_urls) +let ws_url = "wss://ws.dataengine.chain.link"; +let config = Config::new(api_key, api_secret, rest_url, ws_url) // Enable WebSocket HA mode .with_ws_ha(WebSocketHighAvailability::Enabled) // Increase the max reconnection attempts (optional, default is 5) @@ -161,7 +177,9 @@ let config = Config::new(api_key, api_secret, rest_url, ws_urls) .build()?; ``` -- Multiple WebSocket endpoints +**Note:** High Availability mode is only available on mainnet endpoints, not testnet. + +- Automatic origin discovery from a single WebSocket URL - Automatic failover on connection loss - Parallel connections to reduce gaps in data @@ -170,7 +188,7 @@ let config = Config::new(api_key, api_secret, rest_url, ws_urls) The SDK allows you to: - Set `ws_max_reconnect`: The maximum number of reconnection attempts (default: 5) -- Enable HA for multiple WebSocket endpoints +- Enable HA for automatic multi-origin WebSocket connections - Optional `insecure_skip_verify` for TLS Example: @@ -178,9 +196,9 @@ Example: ```rust use chainlink_data_streams_sdk::config::{Config, InsecureSkipVerify, WebSocketHighAvailability}; -let ws_urls = "wss://ws.testnet-dataengine.chain.link"; +let ws_url = "wss://ws.testnet-dataengine.chain.link"; -let config = Config::new(api_key, api_secret, rest_url, ws_urls) +let config = Config::new(api_key, api_secret, rest_url, ws_url) .with_ws_ha(WebSocketHighAvailability::Enabled) .with_ws_max_reconnect(5) .with_insecure_skip_verify(InsecureSkipVerify::Enabled) @@ -232,7 +250,7 @@ The [SDK repository](https://github.com/smartcontractkit/data-streams-sdk/blob/m - Fetching a single report, bulk reports, or paginated reports - Compressing report data - Simple WebSocket streaming -- Multiple WebSocket endpoints (HA) +- WebSocket streaming with HA mode ## Performance Considerations @@ -268,14 +286,14 @@ pub struct ConfigBuilder { - Purpose: Enables or disables HA mode for WebSocket streaming. - Values: - - `WebSocketHighAvailability::Enabled`: Maintains multiple WebSocket connections to different endpoints simultaneously. + - `WebSocketHighAvailability::Enabled`: Discovers available origins from the configured WebSocket URL and maintains multiple connections simultaneously. - `WebSocketHighAvailability::Disabled`: Maintains a single connection. - Default: `Disabled`. - Example Use Case: ```rust - // When you want uninterrupted streaming even if one server goes down: - let config = Config::new(api_key, api_secret, rest_url, "wss://ws1,...,wss://wsN") + // When you want uninterrupted streaming even if one origin goes down: + let config = Config::new(api_key, api_secret, rest_url, "wss://ws.dataengine.chain.link") .with_ws_ha(WebSocketHighAvailability::Enabled) .build()?; ``` diff --git a/src/content/data-streams/tutorials/rust-sdk-stream.mdx b/src/content/data-streams/tutorials/rust-sdk-stream.mdx index aae274cbc9c..e4be5cbbed6 100644 --- a/src/content/data-streams/tutorials/rust-sdk-stream.mdx +++ b/src/content/data-streams/tutorials/rust-sdk-stream.mdx @@ -348,7 +348,7 @@ let config = Config::new( api_key, api_secret, "https://api.dataengine.chain.link".to_string(), // Mainnet endpoint - "wss://ws.dataengine.chain.link,wss://ws.dataengine.chain.link".to_string(), // Multiple WebSocket endpoints + "wss://ws.dataengine.chain.link".to_string(), // Mainnet WebSocket endpoint ) .with_ws_ha(WebSocketHighAvailability::Enabled) // Enable WebSocket High Availability Mode .build()?; @@ -357,6 +357,8 @@ let config = Config::new( // ... existing code ... ``` +When `WebSocketHighAvailability::Enabled` is set, the SDK automatically discovers multiple origin endpoints behind the single URL and establishes separate connections to each origin. + See more details about HA mode in the [SDK Reference](/data-streams/reference/data-streams-api/rust-sdk#high-availability-mode). ### Decoded report details diff --git a/src/content/datalink/llms-full.txt b/src/content/datalink/llms-full.txt index a735866c371..1828786d50a 100644 --- a/src/content/datalink/llms-full.txt +++ b/src/content/datalink/llms-full.txt @@ -2359,22 +2359,22 @@ In this example, we're using report schema `v4` for the EUR/USD feed, but your i [...] ``` -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: - -1. Adding multiple WebSocket endpoints in the configuration: - - ```rust - "wss://ws.testnet-dataengine.chain.link,wss://ws.testnet-dataengine.chain.link" - ``` - -2. Enabling HA mode in the configuration: - ```rust - use chainlink_data_streams_sdk::config::WebSocketHighAvailability; - // ... - .with_ws_ha(WebSocketHighAvailability::Enabled) - ``` +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). Use a mainnet WebSocket URL and enable HA mode in the configuration: + +```rust +use chainlink_data_streams_sdk::config::WebSocketHighAvailability; + +let config = Config::new( + api_key, + api_secret, + "https://api.dataengine.chain.link", + "wss://ws.dataengine.chain.link", +) +.with_ws_ha(WebSocketHighAvailability::Enabled) +.build()?; +``` -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. +When HA mode is enabled, the SDK discovers available origins from the configured WebSocket URL and maintains concurrent connections to different instances. This ensures high availability, fault tolerance, and minimizes the risk of report gaps. #### Decoded report details diff --git a/src/content/datalink/pull-delivery/tutorials/stream-decode/ws-rust.mdx b/src/content/datalink/pull-delivery/tutorials/stream-decode/ws-rust.mdx index a12454dcd09..eb81badfa27 100644 --- a/src/content/datalink/pull-delivery/tutorials/stream-decode/ws-rust.mdx +++ b/src/content/datalink/pull-delivery/tutorials/stream-decode/ws-rust.mdx @@ -271,22 +271,22 @@ In this example, we're using report schema `v4` for the EUR/USD feed, but your i [...] ``` -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: - -1. Adding multiple WebSocket endpoints in the configuration: - - ```rust - "wss://ws.testnet-dataengine.chain.link,wss://ws.testnet-dataengine.chain.link" - ``` - -1. Enabling HA mode in the configuration: - ```rust - use chainlink_data_streams_sdk::config::WebSocketHighAvailability; - // ... - .with_ws_ha(WebSocketHighAvailability::Enabled) - ``` - -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. +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). Use a mainnet WebSocket URL and enable HA mode in the configuration: + +```rust +use chainlink_data_streams_sdk::config::WebSocketHighAvailability; + +let config = Config::new( + api_key, + api_secret, + "https://api.dataengine.chain.link", + "wss://ws.dataengine.chain.link", +) +.with_ws_ha(WebSocketHighAvailability::Enabled) +.build()?; +``` + +When HA mode is enabled, the SDK discovers available origins from the configured WebSocket URL and maintains concurrent connections to different instances. This ensures high availability, fault tolerance, and minimizes the risk of report gaps. #### Decoded report details