Skip to content

Commit 7fcda87

Browse files
committed
PCX review. Adding glossary term for "event context", definition TBC.
1 parent 327660b commit 7fcda87

File tree

3 files changed

+27
-33
lines changed

3 files changed

+27
-33
lines changed

src/content/docs/durable-objects/api/state.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ sidebar:
55
order: 4
66
---
77

8-
import { Tabs, TabItem } from "~/components";
8+
import { Tabs, TabItem, GlossaryTooltip } from "~/components";
99

1010
## Description
1111

@@ -53,7 +53,7 @@ export class MyDurableObject extends DurableObject {
5353

5454
### `waitUntil`
5555

56-
`waitUntil` waits until the promise which is passed as a parameter resolves and can extends an event context up to 30 seconds after the last client disconnects.
56+
`waitUntil` waits until the promise which is passed as a parameter resolves and can extends an <GlossaryTooltip term= "event context">event context</GlossaryTooltip> up to 30 seconds after the last client disconnects.
5757

5858
:::note[`waitUntil` is not necessary]
5959

@@ -71,13 +71,13 @@ The event context for a Durable Objects extends at least 60 seconds after the la
7171

7272
### `blockConcurrencyWhile`
7373

74-
`blockConcurrencyWhile` executes an async callback while blocking any other events from being delivered to the Durable Object instance until the callback completes. This method guarantees ordering and prevents concurrent requests. All events that were not explicitly initiated as part of the callback itself will be blocked. Once the callback completes, All other events will be delivered.
74+
`blockConcurrencyWhile` executes an async callback while blocking any other events from being delivered to the Durable Object instance until the callback completes. This method guarantees ordering and prevents concurrent requests. All events that were not explicitly initiated as part of the callback itself will be blocked. Once the callback completes, all other events will be delivered.
7575

76-
`blockConcurrencyWhile` is commonly used within the constructor of the Durable Object class to enforce that initialization must occur before any requests are delivered. Another use case is executing `async` operations based on the current state of the Durable Object instance and using `blockConcurrencyWhile` to prevent that state from changing while yeilding the event loop.
76+
`blockConcurrencyWhile` is commonly used within the constructor of the Durable Object class to enforce initialization to occur before any requests are delivered. Another use case is executing `async` operations based on the current state of the Durable Object instance and using `blockConcurrencyWhile` to prevent that state from changing while yielding the event loop.
7777

7878
If the callback throws an exception, the object will be terminated and reset. This ensures that the object cannot be left stuck in an uninitialized state if something fails unexpectedly. To avoid this behavior, enclose the body of your callback in a `try...catch` block to ensure it cannot throw an exception.
7979

80-
To help mitigate deadlocks there is a 30s timeout applied when executing the callback. If this timeout is exceeded the Durable Object instance will be reset. It is best practice to have the callback do as little work as possible to improve overall request throughput to the Durable Object instance.
80+
To help mitigate deadlocks there is a 30 second timeout applied when executing the callback. If this timeout is exceeded, the Durable Object instance will be reset. It is best practice to have the callback do as little work as possible to improve overall request throughput to the Durable Object instance.
8181

8282
```js
8383
// Durable Object
@@ -131,7 +131,7 @@ The WebSocket Hibernation API permits a maximum of 32,768 WebSocket connections
131131

132132
:::note[`waitUntil` is not necessary]
133133

134-
Disconnected WebSockets are not returned by this method, but `getWebSockets` may still return websockets even after `ws.close` has been called. For example, if the server-side WebSocket sends a close, but does not receive one back (and has not detected a disconnect from the client), then the connection is in the CLOSING 'readyState'. The client might send more messages, so the WebSocket is technically not disconnected.
134+
Disconnected WebSockets are not returned by this method, but `getWebSockets` may still return WebSockets even after `ws.close` has been called. For example, if the server-side WebSocket sends a close, but does not receive one back (and has not detected a disconnect from the client), then the connection is in the CLOSING 'readyState'. The client might send more messages, so the WebSocket is technically not disconnected.
135135

136136
:::
137137

@@ -141,7 +141,7 @@ Disconnected WebSockets are not returned by this method, but `getWebSockets` may
141141

142142
#### Return values
143143

144-
- An `Array<WebSocket>`
144+
- An `Array<WebSocket>`.
145145

146146
### `setWebSocketAutoResponse`
147147

@@ -153,7 +153,7 @@ Disconnected WebSockets are not returned by this method, but `getWebSockets` may
153153

154154
#### Parameters
155155

156-
- An optional `WebSocketRequestResponsePair(request string, response string)` enabling any WebSocket accepted via [`DurableObjectState::acceptWebSocket`](/durable-objects/api/state/#acceptwebsocket) to automatically reply to the provided response when it receives the provided request. Both request and response are limited to 2,048 characters each. If the parameter is omitted any previously set auto-response configuration will be removed. [`DurableObjectState::getWebSocketAutoResponseTimestamp`](/durable-objects/api/state/#getwebsocketautoresponsetimestamp) will still reflect the last timestamp that an auto-response was sent.
156+
- An optional `WebSocketRequestResponsePair(request string, response string)` enabling any WebSocket accepted via [`DurableObjectState::acceptWebSocket`](/durable-objects/api/state/#acceptwebsocket) to automatically reply to the provided response when it receives the provided request. Both request and response are limited to 2,048 characters each. If the parameter is omitted, any previously set auto-response configuration will be removed. [`DurableObjectState::getWebSocketAutoResponseTimestamp`](/durable-objects/api/state/#getwebsocketautoresponsetimestamp) will still reflect the last timestamp that an auto-response was sent.
157157

158158
#### Return values
159159

@@ -175,7 +175,7 @@ Disconnected WebSockets are not returned by this method, but `getWebSockets` may
175175

176176
#### Return values
177177

178-
- A `WebSocketRequestResponsePair` or null
178+
- A `WebSocketRequestResponsePair` or null.
179179

180180
### `getWebSocketAutoResponseTimestamp`
181181

@@ -219,7 +219,7 @@ If no parameter or a parameter of `0` is provided and a timeout has been previou
219219

220220
#### Return values
221221

222-
- A number or null if the timeout has not been set.
222+
- A number, or null if the timeout has not been set.
223223

224224
### `getTags`
225225

src/content/docs/durable-objects/api/websockets.mdx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,7 @@ To learn more about WebSocket Hibernation, refer to [Build a WebSocket server wi
144144

145145
### webSocketMessage
146146

147-
- <code>
148-
webSocketMessage(ws <Type text="WebSocket" />, message{" "}
149-
<Type text="string | ArrayBuffer" />)
150-
</code>
151-
: <Type text="void" />
147+
- <code> webSocketMessage(ws <Type text="WebSocket" />, message{" "} <Type text="string | ArrayBuffer" />)</code>: <Type text="void" />
152148

153149
- Called by the system when an accepted WebSocket receives a message.
154150

@@ -158,21 +154,15 @@ To learn more about WebSocket Hibernation, refer to [Build a WebSocket server wi
158154

159155
### webSocketClose
160156

161-
- <code>
162-
webSocketClose(ws <Type text="WebSocket" />, code <Type text="number" />,
163-
reason <Type text="string" />, wasClean <Type text="boolean" />)
164-
</code>
165-
: <Type text="void" />
157+
- <code> webSocketClose(ws <Type text="WebSocket" />, code <Type text="number" />,reason <Type text="string" />, wasClean <Type text="boolean" />)</code>: <Type text="void" />
166158

167159
- Called by the system when a WebSocket is closed. `wasClean()` is true if the connection closed cleanly, false otherwise.
168160

169161
- This method can be `async`.
170162

171163
### webSocketError
172164

173-
- <code>
174-
webSocketError(ws <Type text="WebSocket" />, error <Type text="any" />)
175-
</code> : <Type text="void" />
165+
- <code> webSocketError(ws <Type text="WebSocket" />, error <Type text="any" />)</code> : <Type text="void" />
176166

177167
- Called by the system when any non-disconnection related errors occur.
178168

src/content/glossary/durable-objects.yaml

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@ entries:
55
general_definition: |-
66
The product name, or the collective noun referring to more than one Durable Object instance.
77
8-
- term: "Namespace"
8+
- term: "namespace"
99
general_definition: |-
10-
A container for a collection of Durable Objects that all share the same Durable Object (class) definition. A single Namespace can have (tens of) millions of Durable Objects. Metrics are scoped per Namespace.
10+
A container for a collection of Durable Objects that all share the same Durable Object (class) definition. A single namespace can have (tens of) millions of Durable Objects. Metrics are scoped per namespace.
1111
1212
- term: "Durable Object"
1313
general_definition: |-
14-
An individual Durable Object. A Durable Object is globally unique (referenced by ID), provides a global point of coordination for all methods/requests sent to it, and has private, persistent storage that is not shared with other Durable Objects within a Namespace.
14+
An individual instance of a Durable Object class. A Durable Object is globally unique (referenced by ID), provides a global point of coordination for all methods/requests sent to it, and has private, persistent storage that is not shared with other Durable Objects within a namespace.
1515
16-
- term: "Stub"
16+
- term: "stub"
1717
general_definition: |-
18-
An object that refers to a unique Durable Object within a Namespace and allows you to call into that Durable Object via RPC methods or the `fetch` API. For example, `let stub = env.MY_DURABLE_OBJECT.get(id)`
18+
An object that refers to a unique Durable Object within a namespace and allows you to call into that Durable Object via RPC methods or the `fetch` API. For example, `let stub = env.MY_DURABLE_OBJECT.get(id)`
1919
2020
- term: "actor"
2121
general_definition: |-
22-
A term referring to a unique Durable Object.
22+
A term referring to a unique Durable Object. See "Durable Object".
2323
2424
- term: "instance"
2525
general_definition: |-
26-
See 'actor'.
26+
See "actor".
2727
2828
- term: "Durable Object class"
2929
general_definition: |-
30-
The JavaScript class that defines the methods (RPC) and handlers (`fetch`, `alarm`) as part of your Durable Object, and/or an optional `constructor`. All Durable Objects within a single Namespace share the same class definition.
30+
The JavaScript class that defines the methods (RPC) and handlers (`fetch`, `alarm`) as part of your Durable Object, and/or an optional `constructor`. All Durable Objects within a single namespace share the same class definition.
3131
3232
- term: "Storage Backend"
3333
general_definition: |-
@@ -50,7 +50,7 @@ entries:
5050
general_definition: |-
5151
API methods part of Storage API that support SQL querying.
5252
53-
- term: Migration
53+
- term: "migration"
5454
general_definition: |-
5555
A Durable Object migration is a mapping process from a class name to a runtime state.
5656
Initiate a Durable Object migration when you need to:
@@ -60,6 +60,10 @@ entries:
6060
- Delete a Durable Object class.
6161
- Transfer an existing Durable Objects class.
6262
63-
- term: Alarm
63+
- term: "alarm"
6464
general_definition: |-
6565
A Durable Object alarm is a mechanism that allows you to schedule the Durable Object to be woken up at a time in the future.
66+
67+
- term: "event context"
68+
general_definition: |-
69+
The duration for which a Durable Object is kept in memory.

0 commit comments

Comments
 (0)