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

    Deleted User

    12/17/2022, 3:48 AM
    Do
    NS.newUniqueId()
    /
    NS.idFromName(name)
    , or
    NS.get(id)
    incur costs? Or are they billed as reads or are reads/writes related to
    this.state.storage
    reads?
  • b

    brett

    12/17/2022, 3:58 AM
    No cost for the first 3.
    fetch
    would be where you're charged for invocation, and yes
    state.storage
    are where read/writes are billed
  • a

    Alexander.Xtreme

    12/17/2022, 9:03 AM
    Yes, I could use a DO to handle consistency, then place it in the kv to be available everywhere... So according to Brett, there is no benefit in that, so...
  • j

    Jacob Wright

    12/18/2022, 4:13 AM
    So, you’ve built R2 on Durable objects, D1, and queues. You got any plans for full text search? Pretty please.
  • h

    HardAtWork

    12/18/2022, 10:33 AM
    There are some projects exploring this already. Lyra.js should be DO compatible, and https://github.com/drivly/searches.do was built for Durable Objects
  • h

    HardAtWork

    12/18/2022, 10:33 AM
    Though there are definitely some limitations that will be hard to overcome
  • m

    mpeg

    12/18/2022, 7:33 PM
    I'm having some issues getting a DO that works locally to work on the live pages.dev site, is this because pages still ignores wrangler.toml even if using "Pages Functions" in advanced mode? I'm not sure what to do to use DO from pages
  • d

    DanTheGoodman

    12/19/2022, 12:02 AM
    Weird question: Is it possible to run arbitrary external code from within a durable object? Like if wanted to give users their own durable objects and expose an interface for their to iterate over rows and run JS over them, but not let them write, delete, etc.
    s
    • 2
    • 12
  • e

    Eckkert

    12/19/2022, 2:46 AM
    Do yall think we will ever get durable objects on free tier?
  • s

    Stavros

    12/19/2022, 9:22 AM
    When using durable objects, how can i access storage.get and storage.put outside of the class?
  • h

    HardAtWork

    12/19/2022, 9:23 AM
    Pass the class to the function?
  • s

    Stavros

    12/19/2022, 9:26 AM
    Could you send an example? Doesn’t seem to work
  • h

    HardAtWork

    12/19/2022, 9:27 AM
    Copy code
    js
    // Within your DO class
    someFunction(this);
  • s

    Stavros

    12/19/2022, 9:29 AM
    Thanks, is this the only way?
  • h

    HardAtWork

    12/19/2022, 9:30 AM
    You could try to hoist it into the global scope, but I would highly recommend against it.
  • s

    Stavros

    12/19/2022, 9:34 AM
    Alright thank you!
  • h

    HardAtWork

    12/19/2022, 9:35 AM
    No problem!
  • m

    mpeg

    12/19/2022, 3:46 PM
    Anyone know how to use DO from within pages functions? is there a way or should I try a different solution? the docs seem to imply you create the binding in the web UI but it doesn't show anything there
  • u

    Unsmart | Tech debt

    12/19/2022, 3:47 PM
    Have you created a DO yet? You need to create one before you can bind it in pages
  • m

    mpeg

    12/19/2022, 3:49 PM
    that's probably the thing I don't get, how do you create a DO? my DO is currently imported into the same code bundle I'm uploading to pages functions, but I guess that's not enough
  • u

    Unsmart | Tech debt

    12/19/2022, 3:50 PM
    You create the DO with workers
  • m

    mpeg

    12/19/2022, 3:51 PM
    so I create an empty worker that just imports the DO and add it to the wrangler file?
  • m

    mpeg

    12/19/2022, 3:58 PM
    ok I think that works, it's just so clunky :/ I feel the docs do a terrible job of explaining this whole thing
  • m

    mpeg

    12/19/2022, 3:58 PM
    thanks!
  • a

    aranchelk

    12/19/2022, 8:00 PM
    Based on my understanding of DOs, I'm not sure much of the advice you got is correct. They are defined with a JS class, but they run as a separate remote process, meaning you can't just pass the class around, use a closure, etc, everything has to be done via message passing. You use the stub to pass a message (specifically a Request object) from a worker or another DO, you use your the fetch function inside the DO to handle the request. And if the request is going to tell the DO to do a .get() or .put() on the behalf of another DO or worker, you need to define for yourself a little api so the requests contain the get and put instructions. If you haven't done so already, you might just read through these docs: https://developers.cloudflare.com/workers/learning/using-durable-objects/ https://developers.cloudflare.com/workers/runtime-apis/durable-objects/
  • d

    DanTheGoodman

    12/20/2022, 4:13 PM
    Hey is the number of classes you can make for durable objects unlimited too?
  • h

    HardAtWork

    12/20/2022, 4:26 PM
    As long as they fit within the size of the script/script number limit, iirc
  • h

    HardAtWork

    12/20/2022, 4:26 PM
    Also, WDL is currently experiencing issues with AE queries. Gonna try to get a patch out for that asap
  • d

    DanTheGoodman

    12/20/2022, 4:26 PM
    script number limit? I don't see that in the docs
  • d

    DanTheGoodman

    12/20/2022, 4:27 PM
    oh I see, it's a worker limit
1...461462463...567Latest