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
It is confusing to say that the binding name is `MY_DURABLE_OBJECT` — singular — and then call methods on it in order to....get a single Durable Objects instance.
I don't think this creates the correct mental model, makes it seem like `MY_DURABLE_OBJECT` is a single durable object, instead of what it is — a namepaces of Durable Objects — plural.
1. Exported your Worker's main event handlers, such as the `fetch()` handler for receiving HTTP requests.
146
146
2. Passed `env` into the `fetch()` handler. Bindings are delivered as a property of the environment object passed as the second parameter when an event handler or class constructor is invoked. By calling the `idFromName()` function on the binding, you use a string-derived object ID. You can also ask the system to [generate random unique IDs](/durable-objects/api/namespace/#newuniqueid). System-generated unique IDs have better performance characteristics, but require you to store the ID somewhere to access the Object again later.
147
-
3. Derived an object ID from the URL path. `MY_DURABLE_OBJECT.idFromName()` always returns the same ID when given the same string as input (and called on the same class), but never the same ID for two different strings (or for different classes). In this case, you are creating a new object for each unique path.
147
+
3. Derived an object ID from the URL path. `MY_DURABLE_OBJECT_NAMESPACE.idFromName()` always returns the same ID when given the same string as input (and called on the same class), but never the same ID for two different strings (or for different classes). In this case, you are creating a new object for each unique path.
148
148
4. Constructed the stub for the Durable Object using the ID. A stub is a client object used to send messages to the Durable Object.
149
149
5. Called a Durable Object by invoking a RPC method, `sayHello()`, on the Durable Object, which returns a `Hello, World!` string greeting.
150
150
6. Received an HTTP response back to the client by constructing a HTTP Response with `return new Response()`.
@@ -153,13 +153,13 @@ Refer to [Access a Durable Object from a Worker](/durable-objects/best-practices
153
153
154
154
## 4. Configure Durable Object bindings
155
155
156
-
[Bindings](/workers/runtime-apis/bindings/) allow your Workers to interact with resources on the Cloudflare developer platform. The Durable Object bindings in your Worker project's [Wrangler configuration file](/workers/wrangler/configuration/) will include a binding name (for this guide, use `MY_DURABLE_OBJECT`) and the class name (`MyDurableObject`).
156
+
[Bindings](/workers/runtime-apis/bindings/) allow your Workers to interact with resources on the Cloudflare developer platform. The Durable Object bindings in your Worker project's [Wrangler configuration file](/workers/wrangler/configuration/) will include a binding name (for this guide, use `MY_DURABLE_OBJECT_NAMESPACE`) and the class name (`MyDurableObject`).
157
157
158
158
<WranglerConfig>
159
159
160
160
```toml
161
161
[[durable_objects.bindings]]
162
-
name = "MY_DURABLE_OBJECT"
162
+
name = "MY_DURABLE_OBJECT_NAMESPACE"
163
163
class_name = "MyDurableObject"
164
164
```
165
165
@@ -235,9 +235,9 @@ export class MyDurableObject extends DurableObject<Env> {
0 commit comments