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

    erik-beus

    04/20/2023, 8:33 AM
    I see. So the
    alarm()
    function should have access to any variable on the DO? And there's nothing stopping the
    alarm()
    function from calling the DO over http? (although it doesn't make much sense if it has access to variables)
  • h

    HardAtWork

    04/20/2023, 8:34 AM
    It should, yes. There shouldn't be any restrictions in calling itself on the
    fetch
    , but if a variable isn't defined in the
    alarm
    , then it probably won't be defined in the
    fetch
    either, unless it is implicitly created.
  • e

    erik-beus

    04/20/2023, 8:35 AM
    Alright. I'll debug a bit more. Thank you for your input 👍
  • u

    0xcaff

    04/20/2023, 8:59 PM
    curious, has there been any progress on this? this is a major annoyance for our workload 🙏
  • e

    equanimityhow

    04/20/2023, 10:49 PM
    Hello, I'm wondering if its possible to tell which data center a DO is currently running. From what I'm seeing in my logs I believe that IncomingRequestCFProperties#colo is the data center where the request enters CloudFlare's network, and not necessarily where the DO is running. https://developers.cloudflare.com/workers/runtime-apis/request/#incomingrequestcfproperties
  • Yeah that will be the request it came
    u

    Unsmart | Tech debt

    04/20/2023, 10:52 PM
    Yeah that will be the request it came from not the DO colo. Right now it is possible to do /cdn-cgi/trace, but there has been a discussion about that being removed so it wont be possible to tell.
    e
    • 2
    • 4
  • h

    HASA

    04/21/2023, 2:26 PM
    Hey guys. So considering that DO persistent storage is a kv storage system, it makes it kind of limited in applications we can use it for. I was wondering how you guys get around that? Like say I am creating an e-commerce order system. Would I just create an array to store all of the ids of the unfulfilled orders? I could see that getting real ugly real quick in my head? I just need some capabilities past simply retrieve an object by id?
  • k

    kenton

    04/21/2023, 2:39 PM
    You could have a set of keys named
    unfulfilled:<id>
    , then you can list unfulfilled orders by doing a
    list()
    operation with
    prefix: "unfulfilled:"
    .
  • h

    HASA

    04/21/2023, 2:40 PM
    Oh that’s interesting. Researching it. How many ids could it store before I have to worry about 500ms+ slowdowns
  • k

    kenton

    04/21/2023, 2:42 PM
    Lots. It should perform similarly to if you had a database with a table and you were SELECTing from the table.
  • k

    kenton

    04/21/2023, 2:44 PM
    of course, it's less convenient than a SQL database in that you have to maintain your "indexes" manually by creating a separate range of keys that you can query like this.
  • k

    kenton

    04/21/2023, 2:44 PM
    We have some ideas in the works for making this better.
  • h

    HASA

    04/21/2023, 2:48 PM
    So is the list method available in durable objects persistent storage or only on kv
  • h

    HASA

    04/21/2023, 2:48 PM
    Anyway I can see an example somewhere?
  • k

    kenton

    04/21/2023, 2:49 PM
    I'm talking about Durable Objects storage here, which has a key/value interface. Workers KV is totally different.
  • h

    HASA

    04/21/2023, 2:49 PM
    Yeah that’s what I’m interested In DO persistent storage
  • h

    HASA

    04/21/2023, 2:51 PM
    Here’s my situation: I have data like ex orders. For these orders I have a requirement where I have multiple clients even across the world (not required by preferred) mutating it at the same time. I thought early in the lifecycle store the orders in DO to get the strong consistency and then when order is closed delete from DO and store in sql database
  • k

    kenton

    04/21/2023, 2:51 PM
    Not sure about a good example. The chat demo only stores one "table" in its storage: message logs, keyed by timestamp. So it doesn't need prefixes. But here's where it performs a list(): https://github.com/cloudflare/workers-chat-demo/blob/master/src/chat.mjs#L295
  • h

    HASA

    04/21/2023, 2:52 PM
    So do you think this list method is a good approach to get a little more capabilities then just kv query. Do you think it should be sufficient for my use case where the most open orders per DO storage is maybe 500-1000 at most
  • k

    kenton

    04/21/2023, 2:53 PM
    yes, listing 1000 items should be no problem
  • h

    HASA

    04/21/2023, 2:54 PM
    Okay do you think it’s a decent approach to delete the orders every night on DO and migrate them to a sql database
  • k

    kenton

    04/21/2023, 2:55 PM
    I guess I don't know enough about your app to evaluate that
  • k

    kenton

    04/21/2023, 2:55 PM
    could be a fine solution depending on the problem
  • h

    HASA

    04/21/2023, 2:57 PM
    Basically the orders are only really used the day they are created. But maybe 10 days in future customer wants to see his order. We could then just retrieve it from sql database. Basically I’m using DO storage to allow strong consistency the day order is created since multiple clients will mutate simultaneously. But then after that day no collaboration on mutations needed at most maybe one person will mutate something in order like give refund.
  • h

    HASA

    04/21/2023, 3:00 PM
    Do you think 3 people working on the same order simultaneously across the world will have a good experience if the order is stored in durable objects persistent storage? Or would it need to be in the memory to get real time experience
  • l

    Larry

    04/21/2023, 6:57 PM
    Workers KV also has a list with prefix query pattern. I'm using it in both KV and DO.
  • k

    kenton

    04/21/2023, 7:05 PM
    It does, but it's more limited: It only lists in forward order, it's relatively slow, and it doesn't return values. Workers KV's list() is intended to be a less-used operation whereas with DO it's expected that list() is how you do queries all the time.
  • s

    shapeshifter

    04/21/2023, 9:20 PM
    I've tried hunting in here and through the docs but I don't think I'm finding my exact answers. If I make a change to a DO that is published (modifying methods), do I then need to run a migration or are migrations only for data changes that occur?
  • s

    shapeshifter

    04/21/2023, 9:21 PM
    and if a migration needs to be made to the same DO class like that, how would i make the migration using wrangler.toml? would it be a rename?
  • s

    shapeshifter

    04/21/2023, 9:25 PM
    JK, I think I found it can anyone confirm that this still applies? https://discord.com/channels/595317990191398933/773219443911819284/1012363908562030632
1...539540541...567Latest