-
Notifications
You must be signed in to change notification settings - Fork 421
Add noop jurisdictions in workerd #4745
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
Conversation
// Check that no two DurableObjectId created via `newUniqueId()` are equal. | ||
const id1 = env.ns.newUniqueId(); | ||
const id2 = env.ns.newUniqueId(); | ||
assert.equal(id1.equals(id2), false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.equal(id1.equals(id2), false); | |
assert.ok(!id1.equals(id2)); |
// }); | ||
assert.throws(() => { | ||
euNs.jurisdiction('fedramp'); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.throws(...)
really ought to have a second argument to test the error type and message (here and in the other cases below).
// jurisdictions. | ||
const id1 = euNs.newUniqueId(); | ||
const id2 = euNs.newUniqueId(); | ||
assert.equal(id1.equals(id2), false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.equal(id1.equals(id2), false); | |
assert.ok(!id1.equals(id2)); |
assert.equal(id1.equals(id2), false); | ||
assert.equal(id2.equals(id3), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert.equal(id1.equals(id2), false); | |
assert.equal(id2.equals(id3), true); | |
assert.ok(!id1.equals(id2)); | |
assert.ok(id2.equals(id3)); |
src/workerd/server/actor-id-impl.c++
Outdated
@@ -87,14 +108,28 @@ kj::Own<ActorIdFactory::ActorId> ActorIdFactoryImpl::idFromString(kj::String str | |||
JSG_REQUIRE(kj::arrayPtr(id).slice(BASE_LENGTH).startsWith(decoded.asPtr().slice(BASE_LENGTH)), | |||
TypeError, "Durable Object ID is not valid for this namespace."); | |||
|
|||
return kj::heap<ActorIdImpl>(id, kj::none); | |||
// TODO(jhoward): This has an issue that an actor ID will loose its jurisdiction after being |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: we don't typically use names in the TODO comments... generally these should be like TODO(soon)
, TODO(cleanup)
, etc.
src/workerd/server/actor-id-impl.c++
Outdated
"Cannot create a jurisdictional subnamespace from a subnamespace that already " | ||
"has a jurisdiction set"); | ||
// TODO(jhoward): Do these warnings show up in local dev? | ||
KJ_LOG(WARNING, "jurisdiction restrictions have no affect in workerd", jurisdiction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might make sense to make this LOG_ONCE
or LOG_PERIODICALLY
src/workerd/server/actor-id-impl.c++
Outdated
bool ActorIdFactoryImpl::matchesJurisdiction(const ActorId& id) { | ||
bool ActorIdFactoryImpl::matchesJurisdiction(const ActorId& abstractId) { | ||
// TODO(jhoward): Is there something more idiomatic here? KJ_IF_SOME gives me an unused variable, | ||
// but the tour says to avoid checking kj::none explicitly. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pattern is fine. You could use a maybeJurisdiction.map(...)
but to my eyes that's less readable.
src/workerd/server/actor-id-impl.h
Outdated
ActorIdImpl(const kj::byte idParam[SHA256_DIGEST_LENGTH], kj::Maybe<kj::String> name); | ||
ActorIdImpl(const kj::byte idParam[SHA256_DIGEST_LENGTH], | ||
kj::Maybe<kj::String> name, | ||
kj::Maybe<kj::String> maybeJurisdiction); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kj::Maybe<kj::String> maybeJurisdiction); | |
kj::Maybe<kj::String> maybeJurisdiction = kj::none); |
9d1ae14
to
3059777
Compare
If anyone else is confused by the history of this PR like me it shows as merged because the branch name used in this PR was reused in another PR. The commit that was merged into master is 3059777 which does not reflect the changes that James commented on or that match the description "Add noop jurisdictions in workerd". The decision to not "Add noop jurisdictions in workerd" is due to the fact that jurisdictions have no meaning in workerd and to make them match Cloudflare's production environment we would have to change the way that we encode DurableObjectIds in workerd and therefore either break customers or maintain a mechanism for reading older DurableObjectIds before supporting jurisdictions. This is just more trouble than it is worth. The alternative that we will pursue is to allow jurisdictions to be nullish for workerd so that local development is easier for customers. E.g.
vs.
Assuming that JURISDICTION is a env variable set on production. |
I am on the fence whether this is worthwhile. I don't like it because the jurisdictions feature makes no sense in workerd, but customers would like to have jurisdiction support in local development. This adds jurisdictions which effectively do nothing, but should have the same properties that they do in edgeworker. This changes the way that actor IDs are computed in workerd, which is technically a breaking change.