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/index.mdx
+10Lines changed: 10 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,15 @@ Chainlink Data Streams offers price points such as mid prices and [Liquidity-Wei
50
50
51
51
Data Streams API services use an [active-active multi-site deployment](/data-streams/architecture#active-active-multi-site-deployment) model across multiple distributed and isolated origins. This architecture ensures continuous operations even if one origin fails, delivering robust fault tolerance and high availability.
52
52
53
+
For real-time streaming applications, the SDKs support **High Availability (HA) mode** that establishes multiple simultaneous connections for zero-downtime operation. When enabled, HA mode provides:
54
+
55
+
-**Automatic failover** between connections
56
+
-**Report deduplication** across connections
57
+
-**Automatic origin discovery** to find available endpoints
Access to low-latency, high-frequency data enables a variety of onchain applications:
@@ -82,6 +91,7 @@ Access data directly through REST APIs or WebSocket connections using our SDKs:
82
91
83
92
-**[Go SDK](/data-streams/reference/data-streams-api/go-sdk)** - Full-featured SDK with comprehensive examples
84
93
-**[Rust SDK](/data-streams/reference/data-streams-api/rust-sdk)** - High-performance SDK for Rust applications
94
+
-**[TypeScript SDK](/data-streams/reference/data-streams-api/ts-sdk)** - Type-safe SDK for TypeScript applications
85
95
-**[REST API](/data-streams/reference/data-streams-api/interface-api)** or **[WebSocket](/data-streams/reference/data-streams-api/interface-ws)** - Direct access to Data Streams endpoints
Copy file name to clipboardExpand all lines: src/content/data-streams/reference/data-streams-api/authentication/go-examples.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Below are complete examples for authenticating with the Data Streams API in Go.
17
17
18
18
To learn more about the Data Streams API authentication, see the [Data Streams Authentication](/data-streams/reference/data-streams-api/authentication) page.
19
19
20
-
**Note**: The Data Streams SDKs handle authentication automatically. If you're using the [Go SDK](/data-streams/reference/data-streams-api/go-sdk) or [Rust SDK](/data-streams/reference/data-streams-api/rust-sdk), you don't need to implement the authentication logic manually.
20
+
**Note**: The Data Streams SDKs handle authentication automatically. If you're using the [Go SDK](/data-streams/reference/data-streams-api/go-sdk), [Rust SDK](/data-streams/reference/data-streams-api/rust-sdk), or [TypeScript SDK](/data-streams/reference/data-streams-api/ts-sdk), you don't need to implement the authentication logic manually.
Copy file name to clipboardExpand all lines: src/content/data-streams/reference/data-streams-api/authentication/javascript-examples.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Below are complete examples for authenticating with the Data Streams API in Java
17
17
18
18
To learn more about the Data Streams API authentication, see the [Data Streams Authentication](/data-streams/reference/data-streams-api/authentication) page.
19
19
20
-
**Note**: The Data Streams SDKs handle authentication automatically. If you're using the [Go SDK](/data-streams/reference/data-streams-api/go-sdk) or [Rust SDK](/data-streams/reference/data-streams-api/rust-sdk), you don't need to implement the authentication logic manually.
20
+
**Note**: The Data Streams SDKs handle authentication automatically. If you're using the [Go SDK](/data-streams/reference/data-streams-api/go-sdk), [Rust SDK](/data-streams/reference/data-streams-api/rust-sdk), or [TypeScript SDK](/data-streams/reference/data-streams-api/ts-sdk), you don't need to implement the authentication logic manually.
Copy file name to clipboardExpand all lines: src/content/data-streams/reference/data-streams-api/authentication/rust-examples.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Below are complete examples for authenticating with the Data Streams API in Rust
17
17
18
18
To learn more about the Data Streams API authentication, see the [Data Streams Authentication](/data-streams/reference/data-streams-api/authentication) page.
19
19
20
-
**Note**: The Data Streams SDKs handle authentication automatically. If you're using the [Go SDK](/data-streams/reference/data-streams-api/go-sdk) or [Rust SDK](/data-streams/reference/data-streams-api/rust-sdk), you don't need to implement the authentication logic manually.
20
+
**Note**: The Data Streams SDKs handle authentication automatically. If you're using the [Go SDK](/data-streams/reference/data-streams-api/go-sdk), [Rust SDK](/data-streams/reference/data-streams-api/rust-sdk), or [TypeScript SDK](/data-streams/reference/data-streams-api/ts-sdk), you don't need to implement the authentication logic manually.
Copy file name to clipboardExpand all lines: src/content/data-streams/reference/data-streams-api/authentication/typescript-examples.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ Below are complete examples for authenticating with the Data Streams API in Type
17
17
18
18
To learn more about the Data Streams API authentication, see the [Data Streams Authentication](/data-streams/reference/data-streams-api/authentication) page.
19
19
20
-
**Note**: The Data Streams SDKs handle authentication automatically. If you're using the [Go SDK](/data-streams/reference/data-streams-api/go-sdk) or [Rust SDK](/data-streams/reference/data-streams-api/rust-sdk), you don't need to implement the authentication logic manually.
20
+
**Note**: The Data Streams SDKs handle authentication automatically. If you're using the [Go SDK](/data-streams/reference/data-streams-api/go-sdk), [Rust SDK](/data-streams/reference/data-streams-api/rust-sdk), or [TypeScript SDK](/data-streams/reference/data-streams-api/ts-sdk), you don't need to implement the authentication logic manually.
This documentation provides a detailed reference for the Data Streams SDK for Go. It implements a client library that offers a domain-oriented abstraction for interacting with the Data Streams API and enables both point-in-time data retrieval and real-time data streaming with built-in fault tolerance capabilities.
39
44
45
+
## Requirements
46
+
47
+
- Go 1.22.4 or later
48
+
- Valid Chainlink Data Streams credentials
49
+
50
+
## Installation
51
+
52
+
```go
53
+
go get github.com/smartcontractkit/data-streams-sdk/go
@@ -89,24 +111,24 @@ Configuration struct for the client. `Config` specifies the client configuration
89
111
90
112
```go
91
113
typeConfigstruct {
92
-
ApiKeystring// Client API key
93
-
ApiSecretstring// Client API secret
94
-
RestURLstring// Rest API URL
95
-
96
-
WsURLstring// Websocket API URL
97
-
98
-
WsHAbool// Use concurrent connections to multiple Streams servers
99
-
WsMaxReconnectint// Maximum number of reconnection attempts for Stream underlying connections
100
-
LogDebugbool// Log debug information
101
-
InsecureSkipVerifybool// Skip server certificate chain and host name verification
114
+
ApiKeystring// Client API key
115
+
ApiSecretstring// Client API secret
116
+
RestURLstring// Rest API URL
117
+
WsURLstring// Websocket API URL
118
+
WsHAbool// Use concurrent connections to multiple Streams servers
119
+
WsMaxReconnectint// Maximum number of reconnection attempts for Stream underlying connections
120
+
LogDebugbool// Log debug information
121
+
InsecureSkipVerifybool// Skip server certificate chain and host name verification
102
122
Loggerfunc(format string, a ...any) // Logger function
103
123
104
-
//InspectHttp intercepts http responses for rest requests.
124
+
//InspectHttpResponse intercepts http responses for rest requests.
105
125
// The response object must not be modified.
106
126
InspectHttpResponsefunc(*http.Response)
107
127
}
108
128
```
109
129
130
+
**Note**: If `WsMaxReconnect` is not specified, it defaults to 5 attempts.
131
+
110
132
#### `CtxKey` string
111
133
112
134
Custom context key type used for passing additional headers.
@@ -133,8 +155,8 @@ Represents a paginated response of reports.
133
155
134
156
```go
135
157
typeReportPagestruct {
136
-
Reports []*Report// Slice of Report, representing individual report entries.
137
-
NextPageTSuint64// Timestamp for the next page, used for fetching subsequent pages.
158
+
Reports []*ReportResponse// Slice of ReportResponse, representing individual report entries.
159
+
NextPageTSuint64// Timestamp for the next page, used for fetching subsequent pages.
138
160
}
139
161
```
140
162
@@ -206,7 +228,7 @@ type Stats struct {
206
228
- An error state is encountered in any of the underlying connections, such as a network failure.
207
229
208
230
```go
209
-
Read(context.Context) (*Report, error)
231
+
Read(context.Context) (*ReportResponse, error)
210
232
```
211
233
212
234
- `Stats`: Returns statistics about the stream operations as `Stats`.
@@ -221,6 +243,30 @@ type Stats struct {
221
243
Close() error
222
244
```
223
245
246
+
### High Availability (HA) Mode
247
+
248
+
The Data Streams SDK supports High Availability mode for WebSocket connections. When enabled with `WsHA: true`, the SDK maintains concurrent connections to different instances to ensure high availability, fault tolerance and minimize the risk of report gaps.
249
+
250
+
#### HA Mode Behavior
251
+
252
+
When high availability mode is enabled:
253
+
254
+
- The client queries the server for available origins using the `X-Cll-Available-Origins` header
255
+
- Multiple WebSocket connections are established to different server instances
256
+
- Reports are deduplicated when received across connections
257
+
- Partial reconnects occur when some connections fail while others remain active
258
+
- Full reconnects occur when all connections fail
259
+
260
+
#### HA Configuration
261
+
262
+
HA mode is controlled by the `WsHA` field in the client configuration:
263
+
264
+
```go
265
+
config := streams.Config{
266
+
WsHA: true, // Use concurrent connections to multiple Streams servers
267
+
}
268
+
```
269
+
224
270
### Functions
225
271
226
272
#### `New`
@@ -241,9 +287,19 @@ Utility function for logging.
241
287
func LogPrintf(format string, a ...any)
242
288
```
243
289
290
+
### Errors
291
+
292
+
#### `ErrStreamClosed`
293
+
294
+
Error returned when attempting to use a closed stream.
295
+
296
+
```go
297
+
var ErrStreamClosed = fmt.Errorf("client: use of closed Stream")
[Interface](https://github.com/smartcontractkit/data-streams-sdk/blob/main/go/report/report.go#L13) that represents the actual report data and attributes.
395
+
[Interface](https://github.com/smartcontractkit/data-streams-sdk/blob/main/go/report/report.go#L20) that represents the actual report data and attributes.
Use the appropriate version import based on your feed's schema version, which can be determined by calling `feedID.Version()`.
493
+
494
+
For complete field definitions and decoding examples, see the [report schema overview](/data-streams/reference/report-schema-overview) and [fetch tutorial](/data-streams/tutorials/go-sdk-fetch).
0 commit comments