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

    brett

    07/29/2021, 1:55 PM
    Yeah
  • b

    brett

    07/29/2021, 1:56 PM
    Another use for that would be a staging namespace and a production namespace (to have different data, but sometimes the same code impl)
  • j

    john.spurlock

    07/29/2021, 1:56 PM
    But then each would have potentially different data - interesting - yea that's something to think about
  • b

    brett

    07/29/2021, 1:57 PM
    I think of them as servers, yeah. But nobody (including you) can access a DO without going through your workers. So your DO doesn't necessarily need to have an API key, but your worker might want to have some privileged admin endpoint, if that's what you're asking
  • b

    brett

    07/29/2021, 1:58 PM
    I guess to be clear, you could put the auth wherever makes you happy. But the mental model of a single DO (to me anyway) is to think of them as a server. I'm not sure how else you'd read the total count from 100 different places around the world without sending the server a message -- right?
  • j

    john.spurlock

    07/29/2021, 1:59 PM
    One more question about isolate sharing: what objects are eligible for sharing? All objects in the same script? Or only objects of the same class, same namespace?
  • b

    brett

    07/29/2021, 2:00 PM
    Objects in a namespace currently, but that's an impl detail subject to change
  • j

    john.spurlock

    07/29/2021, 2:00 PM
    Great - thanks! i suppose technically you could go as far up as the script level
  • z

    zifera

    07/29/2021, 2:01 PM
    In the example of a simple counter that I want to get the total value from to my worker. In the worker I will have to use something like fetch('/counter/total/'). Inside the DO fetch(request) { if(request === '/counter/total/') return state.storage.counter } Is this the intended way to use it?
  • z

    zifera

    07/29/2021, 2:02 PM
    so you would need routing in the worker and in the DO
  • b

    brett

    07/29/2021, 2:02 PM
    Yep, if your DO needs to handle different kinds of requests then I'd treat it just like any other server and route how you see fit (such as by URL)
  • z

    zifera

    07/29/2021, 2:03 PM
    ok, just making sure! it felt a bit strange to me
  • b

    brett

    07/29/2021, 2:03 PM
    Or if it's really a simple counter you could make GET return the total without incrementing, and POST incr and return the count, etc
  • z

    zifera

    07/29/2021, 2:04 PM
    lets say you would build some sort of website statistics tool with a DO, incrementing the counter is consistent? even if you have a lot of writes per second?
  • b

    brett

    07/29/2021, 2:05 PM
    Yeah, the persistent storage API is consistent in a DO. You just have to keep in mind that any time you
    await
    another request might be served concurrently.
  • b

    brett

    07/29/2021, 2:06 PM
    So you wouldn't want to do a read, then await some fetch to another service, then do a write that expected nobody else to do anything while you were waiting on the fetch. (We do offer transactions. None of this is really different than any other server using, say, Postgres.)
  • b

    brett

    07/29/2021, 2:06 PM
    We have a blog post coming out soon about some improvements here.
  • z

    zifera

    07/29/2021, 2:08 PM
    so if I await the storage.put, and you have concurrent writes coming from other requests, its possible the counter total value will not be correct?
  • z

    zifera

    07/29/2021, 2:14 PM
    If im checking the documentation: https://developers.cloudflare.com/workers/learning/using-durable-objects#example---counter. They are storing it in a variable to make sure the returned value is correct. But im interested in knowing if the actual stored value in the storage will remain correct with a lot of concurrent writes. (same approach as in the example of the docs)
  • d

    Deleted User

    07/29/2021, 2:15 PM
    but as long as they're exported it shouldn't matter if the class has a name (
    MyClass.name
    )... right?
  • b

    brett

    07/29/2021, 2:18 PM
    That example ensures the stored value and returned value are correct
  • z

    zifera

    07/29/2021, 2:18 PM
    Thanks for your help!
  • b

    brett

    07/29/2021, 2:18 PM
    I'm not sure actually, probably easiest to try by adjusting our template code https://github.com/cloudflare/durable-objects-template
  • d

    Deleted User

    07/29/2021, 2:20 PM
    yea idk why i ask tbh, of course i can just try it
  • d

    Deleted User

    07/29/2021, 2:21 PM
    probably won't test it out for a while though, if i do end up actually finishing something i'll probably post an update here i guess
  • v

    vans163

    07/29/2021, 2:49 PM
    Can anyone at cloudflare put eyes on this, seems to be IO blocking bug for long running fetches
  • m

    matt

    07/29/2021, 3:00 PM
    assuming 1.) refers to using a delete class migration, these are equivalent operations
  • w

    Wallacy

    07/29/2021, 8:20 PM
    you can use the itty-durable to call like internal class: https://github.com/kwhitley/itty-durable
  • t

    toinbis

    07/29/2021, 8:58 PM
    https://liveblocks.io -> cool new product launched. Asked if they do not intend to use DO, and it turns out - they are actually using DO: https://news.ycombinator.com/item?id=27998674. Full HN thread here: https://news.ycombinator.com/item?id=27994480 .
  • f

    figgyc

    07/30/2021, 6:12 PM
    Is/will there be a good way to write DOs in webassembly languages like rust?
1...134135136...567Latest