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

    Greg Brimble | Cloudflare Pages

    04/07/2021, 3:30 PM
    Never played with this particular library (and not suggesting it at all), but that's the sort of thing I had in my head.
  • k

    Kevin W - Itty

    04/07/2021, 3:31 PM
    ahhh gotcha, so basically sending serialized operations?
  • g

    Greg Brimble | Cloudflare Pages

    04/07/2021, 3:33 PM
    Yeah. Maybe you could wrap the whole thing in a string so we could write SQL-esque queries at it, but yes: 1) serialize the transaction 2) send to the DO 3) unwrap the serialized form into a set of instructions 4) perform instructions in a transaction 5) return values
  • g

    Greg Brimble | Cloudflare Pages

    04/07/2021, 3:33 PM
    Quite a serious undertaking, and I'm not sure how possible or feasible it would be.
  • g

    Greg Brimble | Cloudflare Pages

    04/07/2021, 3:34 PM
    I think unless you perform the work on the DO though, you'll always get inconsistency bugs somewhere.
  • g

    Greg Brimble | Cloudflare Pages

    04/07/2021, 3:36 PM
    Some thoughts about how you could do transactions in GraphQL: https://discuss.dgraph.io/t/transactions-in-graphql/6861 And why that might be a bad idea: https://graphqlme.com/2018/05/13/transactions-mutations-and-graphql/
  • k

    Kevin W - Itty

    04/07/2021, 3:36 PM
    Yeah... that's what I'm wondering. May be better to simply expose methods on the DO, and pass simple values to the methods for outside input... and/or some of the slightly-weird-but-functional (pun intended) syntax of
    await durable.prop(newValue)
    mentioned above
  • g

    Greg Brimble | Cloudflare Pages

    04/07/2021, 3:37 PM
    Yup, that's literally the TL;DR of both those posts, I think haha
  • k

    Kevin W - Itty

    04/07/2021, 3:39 PM
    I'm just stoked that we'll be able to abstract ANY of this boilerplate away, and stoked what DOs allow us to do in the first place... the pains I ran into with sync issues on a pure KV backend, oh man
  • i

    ickerio

    04/07/2021, 3:42 PM
    Just out of curiosity, has anyone done any benchmarks on durable objects? for example to see the latency between a parent worker and do
  • k

    Kevin W - Itty

    04/07/2021, 4:21 PM
    Yeah this will be the next approach... great points you and @User made!
  • m

    matt

    04/07/2021, 5:19 PM
    @User an alternative to transactions would be implementing promise pipelining/eventual send, ala CapTP (https://github.com/Agoric/agoric-sdk/tree/master/packages/captp), which would allow you to chain operations and then send them as a single request. I haven't played with CapTP in particular, but capnproto RPC (which is used heavily in the Workers Runtime) supports promise pipelining, and it's quite nice to have.
  • m

    matt

    04/07/2021, 5:20 PM
    Proxy and related classes like WeakRef/WeakMap were actually proposed and added to JS by the folks behind CapTP/Agoric for implementing things like this
  • k

    Kevin W - Itty

    04/07/2021, 5:21 PM
    Yeah @User that’s what I was thinking for even the await setter syntax - setters would pipeline a set operation to send to the durable 👍🏼
  • l

    luke

    04/07/2021, 5:24 PM
    Not sure how performant layered proxies are
  • l

    luke

    04/07/2021, 5:26 PM
    But magic sure is fun
  • l

    luke

    04/07/2021, 5:28 PM
    The only library I know that uses them en masse is https://github.com/nx-js/observer-util
  • k

    Kevin W - Itty

    04/07/2021, 5:28 PM
    I mean I wouldn't do that if max throughput was needed, but I suspect anything that needed to be that performant would be isolated to execute within the DO itself, not sent as proxied fetches one a time
  • l

    luke

    04/07/2021, 5:28 PM
    So may be lessons hiding there
  • k

    Kevin W - Itty

    04/07/2021, 5:30 PM
    You may have found me a new toy for Preact @User!
  • k

    Kevin W - Itty

    04/07/2021, 5:30 PM
    looks like a cleaner mobx
  • k

    Kevin W - Itty

    04/07/2021, 5:32 PM
    and only 1.9k vs mobx 16k (before react/preact bindings)
  • l

    luke

    04/07/2021, 5:38 PM
    The other possibility is to use the usual set syntax without the ability to await: updates local state immediately and fires off the request to the DO in parallel to handle changes to persistent storage
  • l

    luke

    04/07/2021, 5:43 PM
    observer-util is a lot of fun! I used it in a scrappy lightweight production app without much trouble. If you're familiar with the nanohtml (previously bel) ecosystem, https://github.com/lukeburns/morphable was my attempt at introducing a reactive layer on top.
  • k

    Kevin W - Itty

    04/07/2021, 6:05 PM
    Yeah there’s def no point in awaiting the set regardless - as others pointed out, that’s awaiting nothing... so may as well fire off the async behind the scenes and use a get or expose a .done() or something on the stub to confirm all promises are resolved
  • a

    Andy

    04/07/2021, 6:55 PM
    Hey everyone, I've been digging into durable objects and getting pretty excited about them. One thing I'm trying to figure out now is the development flow for them. Is there an easy way to run the workers and durable objects locally while developing?
  • k

    Kevin W - Itty

    04/07/2021, 7:25 PM
    not that i'm aware of... durables don't currently work with
    wrangler dev
  • o

    oleksandr

    04/07/2021, 7:29 PM
    that escalated quickly 😄
  • a

    Andy

    04/07/2021, 8:19 PM
    yeah that was my understanding too. I'm guessing really the only way to develop is to publish the worker
  • k

    kenton

    04/07/2021, 8:45 PM
    Yes, sadly, that's the only way right now. We know this is a big problem. Durable Objects present a whole lot of new challenges to how we do previews, so we need some more time to build it out, but we're working on it.
1...525354...567Latest