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
[DO] Recommending restricting DurableObjectNamespace to jurisdiction, rather than DurableObjectID (cloudflare#22494)
* Not recommending newUniqueId(jurisdiction) approach
* Iterating over the docs for clarity and better
information segregation
* Iterating on feedback
* Turning code blocks into in-line code, restructure
* Cleaning up footnote lines
Copy file name to clipboardExpand all lines: src/content/docs/durable-objects/reference/data-location.mdx
+26-21Lines changed: 26 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,30 +19,39 @@ A [`DurableObjectId`](/durable-objects/api/id) will be logged outside of the spe
19
19
20
20
:::
21
21
22
-
Durable Objects can be restricted to a specific jurisdiction either by creating a [`DurableObjectNamespace`](/durable-objects/api/namespace/) restricted to a jurisdiction, or by creating an individual [`DurableObjectId`](/durable-objects/api/id)restricted to a jurisdiction:
22
+
Durable Objects can be restricted to a specific jurisdiction by creating a [`DurableObjectNamespace`](/durable-objects/api/namespace/) restricted to a jurisdiction. All [Durable Object ID methods](/durable-objects/api/id/) are valid on IDs within a namespace restricted to a jurisdiction.
Methods on a [`DurableObjectNamespace`](/durable-objects/api/namespace/) that take a [`DurableObjectId`](/durable-objects/api/id) as a parameter will throw an exception if the parameter is associated with a different jurisdiction. To achieve this, a [`DurableObjectId`](/durable-objects/api/id) encodes its jurisdiction. As a consequence, it is possible to have the same name represent different IDs in different jurisdictions.
29
+
- It is possible to have the same name represent different IDs in different jurisdictions.
console.assert(!euId1.equal(euId2), "This should always be true");
35
+
```
38
36
39
-
Methods on a [`DurableObjectNamespace`](/durable-objects/api/namespace/) that take a [`DurableObjectId`](/durable-objects/api/id) as a parameter will throw an exception if the parameter is associated with a different jurisdiction. However, these methods will not throw an exception if the [`DurableObjectNamespace`](/durable-objects/api/namespace/) is not associated with a jurisdiction. The common case is that any valid [`DurableObjectId`](/durable-objects/api/id) can be used in the top-level namespace's methods.
37
+
- You will run into an error if the jurisdiction on your [`DurableObjectNamespace`](/durable-objects/api/namespace/) and the jurisdiction on [`DurableObjectId`](/durable-objects/api/id) are different.
38
+
- You will not run into an error if the [`DurableObjectNamespace`](/durable-objects/api/namespace/) is not associated with a jurisdiction.
39
+
- All [Durable Object ID methods](/durable-objects/api/id/) are valid on IDs within a namespace restricted to a jurisdiction.
When specifying a jurisdiction, Cloudflare recommends you first create a namespace restricted to a jurisdiction, using `const euSubnamespace = env.MY_DURABLE_OBJECT.jurisdiction("eu")`.
50
+
51
+
Note that it is also possible to specify a jurisdiction by creating an individual [`DurableObjectId`](/durable-objects/api/id) restricted to a jurisdiction, using `const euId = env.MY_DURABLE_OBJECT.newUniqueId({ jurisdiction: "eu" })`.
52
+
53
+
**However, Cloudflare does not recommend this approach.**
54
+
:::
46
55
47
56
### Supported locations
48
57
@@ -90,13 +99,9 @@ Hints are a best effort and not a guarantee. Unlike with jurisdictions, Durable
90
99
| afr | Africa <sup>2</sup> |
91
100
| me | Middle East <sup>2</sup> |
92
101
93
-
<sup>1</sup> Dynamic relocation of existing Durable Objects is planned for the
94
-
future.
102
+
<sup>1</sup> Dynamic relocation of existing Durable Objects is planned for the future.
95
103
96
-
<sup>2</sup> Durable Objects currently do not spawn in this location. Instead,
97
-
the Durable Object will spawn in a nearby location which does support Durable
98
-
Objects. For example, Durable Objects hinted to South America spawn in Eastern
99
-
North America instead.
104
+
<sup>2</sup> Durable Objects currently do not spawn in this location. Instead, the Durable Object will spawn in a nearby location which does support Durable Objects. For example, Durable Objects hinted to South America spawn in Eastern North America instead.
0 commit comments