Skip to content

Commit 7e9e034

Browse files
committed
rate limiting in confidential client update
1 parent a7e810f commit 7e9e034

2 files changed

Lines changed: 71 additions & 2 deletions

File tree

src/content/cre/guides/workflow/using-confidential-http-client/making-requests-go.mdx

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pageId: "guides-workflow-confidential-http-making-requests"
77
metadata:
88
description: "Make confidential HTTP requests in Go: learn to use enclave execution, secret injection, and optional response encryption in your workflows."
99
datePublished: "2026-02-10"
10-
lastModified: "2026-02-10"
10+
lastModified: "2026-05-22"
1111
---
1212

1313
import { Aside } from "@components"
@@ -170,6 +170,42 @@ Run the simulation:
170170
cre workflow simulate
171171
```
172172

173+
## Request timeout
174+
175+
The `Timeout` field on the inner `Request` object controls how long the enclave waits for the external API to respond before cancelling the call. It uses the [`google.protobuf.Duration`](https://protobuf.dev/reference/protobuf/google.protobuf/#duration) type.
176+
177+
**Default and limits:**
178+
179+
- **Default**: If you omit `Timeout`, a default of **5 seconds** is applied.
180+
- **Maximum**: **10 seconds**. Values above this limit will error.
181+
182+
If your API routinely takes longer than 5 seconds, set an explicit timeout so the request does not fail unexpectedly.
183+
184+
Use `durationpb.New()` with a `time.Duration` value on the `Request` field:
185+
186+
```go
187+
import (
188+
"time"
189+
190+
confhttp "github.com/smartcontractkit/cre-sdk-go/capabilities/networking/confidentialhttp"
191+
"google.golang.org/protobuf/types/known/durationpb"
192+
)
193+
194+
result, err := confHTTPClient.SendRequest(runtime, &confhttp.ConfidentialHTTPRequest{
195+
Request: &confhttp.HTTPRequest{
196+
Url: config.URL,
197+
Method: "GET",
198+
MultiHeaders: map[string]*confhttp.HeaderValues{
199+
"Authorization": {Values: []string{"Basic {{.myApiKey}}"}},
200+
},
201+
Timeout: durationpb.New(10 * time.Second),
202+
},
203+
VaultDonSecrets: []*confhttp.SecretIdentifier{
204+
{Key: "myApiKey", Owner: config.Owner},
205+
},
206+
}).Await()
207+
```
208+
173209
## Template syntax for secrets
174210

175211
Secrets are injected into request bodies and headers using Go template syntax: `{{.secretName}}`. The placeholder name must match the `Key` in your `VaultDonSecrets` list.

src/content/cre/guides/workflow/using-confidential-http-client/making-requests-ts.mdx

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pageId: "guides-workflow-confidential-http-making-requests"
77
metadata:
88
description: "Make confidential HTTP requests in TypeScript: learn to use enclave execution, secret injection, and optional response encryption in your workflows."
99
datePublished: "2026-02-10"
10-
lastModified: "2026-02-10"
10+
lastModified: "2026-05-22"
1111
---
1212

1313
import { Aside } from "@components"
@@ -136,6 +136,39 @@ Run the simulation:
136136
cre workflow simulate
137137
```
138138

139+
## Request timeout
140+
141+
The `timeout` field on the inner `request` object controls how long the enclave waits for the external API to respond before cancelling the call. It uses the [Protocol Buffers `Duration`](https://protobuf.dev/reference/protobuf/google.protobuf/#duration) type.
142+
143+
**Default and limits:**
144+
145+
- **Default**: If you omit `timeout`, a default of **5 seconds** is applied.
146+
- **Maximum**: **10 seconds**. Values above this limit will error.
147+
148+
If your API routinely takes longer than 5 seconds, set an explicit timeout so the request does not fail unexpectedly.
149+
150+
Import `Duration` from `@bufbuild/protobuf/wkt` and set `timeout` on the request:
151+
152+
```typescript
153+
import { Duration } from "@bufbuild/protobuf/wkt"
154+
155+
const response = confHTTPClient
156+
.sendRequest(runtime, {
157+
request: {
158+
url: runtime.config.url,
159+
method: "GET",
160+
multiHeaders: {
161+
Authorization: { values: ["Basic {{.myApiKey}}"] },
162+
},
163+
timeout: { seconds: BigInt(10), nanos: 0 } satisfies Duration,
164+
},
165+
vaultDonSecrets: [{ key: "myApiKey", owner: runtime.config.owner }],
166+
})
167+
.result()
168+
```
169+
170+
The JSON form is also accepted: `timeout: { seconds: "10", nanos: 0 }` (using `DurationJson`).
171+
139172
## Template syntax for secrets
140173

141174
Secrets are injected into request bodies and headers using Go template syntax: `{{.secretName}}`. The placeholder name must match the `key` in your `vaultDonSecrets` list.

0 commit comments

Comments
 (0)