https://discord.cloudflare.com logo
Join Discord
Powered by
# durable-objects
  • b

    brett

    12/14/2022, 3:22 PM
    The idea is that in the future we could (will?) start respecting that hint, even if the object existed already.
  • h

    HardAtWork

    12/14/2022, 3:32 PM
    Oh also, little Quality of Life thing, could there be a way for a DO to inherently know where it is? It’s fine if it changes because it is moved, but just that it knows without having to do a trace would be awesome
  • b

    brett

    12/14/2022, 4:19 PM
    It's certainly possible. Whether we'll actually do it... I don't know yet. Are you thinking airport code? Or like the equivalent locationHint? Or?
  • h

    HardAtWork

    12/14/2022, 4:22 PM
    Airport code at the minimum, locationHint could be inferred(though might be cool to have it too). Also, maybe numeric colo/metal ID for Ent(for metrics, to see how many DOs are moved are on one metal at a time).
  • b

    brett

    12/14/2022, 8:02 PM
    Going back up to what I said earlier, if
    idFromName
    supported Jurisdictons, would it confuse anyone that these IDs point to three different objects?
    NS.idFromName("foo")
    NS.idFromName("foo", {jurisdiction:"eu"})
    NS.idFromName("foo", {jurisdiction:"bar"})
    And regardless of whether it'd confuse you, do you have a different idea for the API you'd prefer?
  • s

    Skye

    12/14/2022, 8:09 PM
    I feel like that would be confusing indeed
  • z

    zegevlier

    12/14/2022, 8:24 PM
    , that would be very confusing. I can't think of a better API that could work here though
  • u

    Unsmart | Tech debt

    12/14/2022, 8:31 PM
    realistically I think names should be unique and trying to change the jurisdiction value shouldnt be allowed and if set to something different should throw an error
  • u

    Unsmart | Tech debt

    12/14/2022, 8:34 PM
    (as in if you have
    NS.idFromName("foo", {jurisdiction:"eu"})
    doing
    NS.idFromName("foo", {jurisdiction:"bar"})
    should throw)
  • s

    Skye

    12/14/2022, 8:35 PM
    could have a "quiet" option to not throw the error and just send it to the existing one too?
  • b

    brett

    12/14/2022, 9:14 PM
    Hm, quiet seems like a dangerous thing to pair with jurisdictions, since you'd typically use these to deal with legal compliance.
  • s

    Skye

    12/14/2022, 9:15 PM
    That's fair
  • b

    brett

    12/14/2022, 9:16 PM
    That said, throwing if the same name is used in another Jurisdiction likely isn't going to work in our system anyway. Or it'd be too slow, at least.
  • b

    brett

    12/14/2022, 9:16 PM
    The only other real option on the table is to require you make a namespace per Jurisdiction, and then you'd have to manage them yourself in Wrangler
  • b

    brett

    12/14/2022, 9:17 PM
    And choose which binding to call
    .idFromName
    and
    .get
    on
  • b

    brett

    12/14/2022, 9:18 PM
    That, or we could force you to use a weird method to try and make it more obvious that the objects are different
    NS.idFromName("foo")
    NS.idFromNameWithFlags("foo", {jurisdiction:"eu"})
    NS.idFromNameWithFlags("foo", {jurisdiction:"bar"})
  • b

    Burrito

    12/14/2022, 9:21 PM
    Copy code
    js
    NS.idFromOptions({ name: 'foo' })
    NS.idFromOptions({ name: 'foo', jurisdiction: 'eu' })
    NS.idFromOptions({ name: 'foo', jurisdiction: 'na' })
    Would be less confusion imo, it makes intuitive sense that these are different option objects and thus the ids returned are different and unrelated too.
  • b

    brett

    12/14/2022, 9:22 PM
    Yeah, interesting
  • s

    Skye

    12/14/2022, 9:25 PM
    as long as it's well documented (warning could be a good idea) - lgtm
  • z

    zegevlier

    12/14/2022, 9:39 PM
    I really like this one. It makes it much more clear than having a separate name and options thing does.
  • b

    brett

    12/14/2022, 9:51 PM
    How about
    NS.jurisdiction("eu").idFromName("foo")
  • s

    Skye

    12/14/2022, 9:52 PM
    ooh I'm a fan of that
  • s

    Skye

    12/14/2022, 9:52 PM
    it distintly namespaces the DO under that durisdiction
  • e

    Erwin

    12/15/2022, 12:46 AM
    I think there is a small difference in confusion between
    NS.idFromOptions({ name: 'foo' })
    and
    NS.idFromOptions({ name: 'foo', jurisdiction: 'eu' })
    being different objects than
    NS.idFromOptions({ name: 'foo', jurisdiction: 'eu' })
    and
    NS.idFromOptions({ name: 'foo', jurisdiction: 'na' })
    being different.
  • e

    Erwin

    12/15/2022, 12:50 AM
    As in, that if you explicitly specify two different jurisdictions it is more clear they are different than between one where you don't specify one and one where you do. So maybe all we need is a way to "enforce jurisdictions" on a namespace. But then you get into the issues of we don't have jurisdictions for everything, so you probably need a "other" one.. Certainly a non-trivial thing to get right. Long story short, I think your
    NS.jurisdiction("eu").idFromName("foo")
    is probably the best solution I have seen so far?
  • p

    Plotzes

    12/15/2022, 7:21 AM
    I don't use DOs but after lurking here, I also think the
    NS.jurisdiction("eu").idFromName("foo")
    is the most clear
  • i

    Isaac McFadyen | YYZ01

    12/15/2022, 11:53 AM
    Agreed. Would also be helpful if you could store the "jurisdiction" part and reuse, i.e:
    Copy code
    js
    const eu = NS.jusrisdiction("eu");
    const do1 = eu.idFromName("do1");
    const do2 = eu.idFromName("do2");
    const do3 = eu.idFromName("do3");
  • b

    brett

    12/15/2022, 3:10 PM
    That's the idea, including
    .get
    , so
    eu.get(euId).fetch(...)
    works but
    eu.get(otherJurisdictionId)
    would throw
  • h

    HardAtWork

    12/15/2022, 3:20 PM
    Is there any way to manually generate an ID String without a Worker?
  • b

    brett

    12/15/2022, 3:21 PM
    Hm can you elaborate?
1...456457458...567Latest