Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Durable Object jurisdiction API #540

Merged
merged 7 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/durable-objects/src/namespace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,11 @@ export class DurableObjectNamespace {
this.#ctx = ctx;
}

jurisdiction(_name: string): DurableObjectNamespace {
// Ignore jurisdiction restrictions in local mode
DaniFoldi marked this conversation as resolved.
Show resolved Hide resolved
return this;
}

newUniqueId(_options?: NewUniqueIdOptions): DurableObjectId {
// Create new zero-filled 32 byte buffer
const id = new Uint8Array(32);
Expand Down
7 changes: 7 additions & 0 deletions packages/durable-objects/test/namespace.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,6 +702,12 @@ test("DurableObjectStub: hides implementation details", async (t) => {
t.deepEqual(getObjectProperties(stub), ["fetch", "id", "name"]);
});

test("DurableObjectNamespace: jurisdiction: returns DurableObjectNamespace", (t) => {
const namespace = new DurableObjectNamespace("OBJECT", throws);
const jurisdictionNamespace = namespace.jurisdiction("eu");
t.is(namespace, jurisdictionNamespace);
});

test("DurableObjectNamespace: newUniqueId: generates unique IDs", (t) => {
const namespace = new DurableObjectNamespace("OBJECT", throws);
const id1 = namespace.newUniqueId();
Expand Down Expand Up @@ -818,6 +824,7 @@ test("DurableObjectNamespace: hides implementation details", (t) => {
"get",
"idFromName",
"idFromString",
"jurisdiction",
"newUniqueId",
]);
});
Expand Down