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

    Brizy

    08/20/2021, 11:34 AM
    That's awesome, will definitely help scaling this
  • j

    john.spurlock

    08/20/2021, 5:09 PM
    > If you are in the Durable Objects open beta, you will also be able to view the logs and requests sent to each Durable Object. This is a great tool to help you understand and debug the interactions between your Worker and a Durable Object. 👏👏👏
  • i

    ItsWendell

    08/20/2021, 6:09 PM
    What's the scale you need? Millions of websockets per channel? Is the primary channel always the same or dynamically created?
  • k

    kavinplays

    08/20/2021, 6:23 PM
    is it coming?
  • k

    kavinplays

    08/20/2021, 6:23 PM
    if that's true, i am gonna mess around with miniflare's version
  • b

    Brizy

    08/20/2021, 6:37 PM
    Ideally, I should be able to handle as many websockets as needed by scaling horizontally, but yes millions per channel is a requirement, the channels are dynamically created, if you know what Pusher is, it's something similar to it
  • d

    Deleted User

    08/20/2021, 9:22 PM
    Hey
  • d

    Deleted User

    08/20/2021, 9:22 PM
    Is it possible to call a DO from another DO? Tried to do so but it crashes.
  • v

    Vanessa🦩

    08/20/2021, 9:25 PM
    Works for me
  • h

    HardAtWork

    08/20/2021, 9:40 PM
    Might be me missing something, but is it possible to call a Namespace if it isn't a part of the same script?
  • j

    john.spurlock

    08/20/2021, 9:41 PM
    Yes, it's just a binding - can even be called by the classic non-module-style workers
  • h

    HardAtWork

    08/20/2021, 9:42 PM
    So two Namespaces cannot share the same class name on the same account, then?
  • j

    john.spurlock

    08/20/2021, 9:43 PM
    Actually you can have multiple namespaces with the same script+class name in the same account. In this case each namespace will have separate data storage. Think dev/staging/prod etc.
  • h

    HardAtWork

    08/20/2021, 9:44 PM
    So then how would you designate them in the bindings?
  • j

    john.spurlock

    08/20/2021, 9:44 PM
    The binding points to a namespace by id
  • j

    john.spurlock

    08/20/2021, 9:45 PM
    just like kv
  • h

    HardAtWork

    08/20/2021, 9:48 PM
    Very confused now. I was reading the docs, and it mentions a binding variable, and a class name, but no mention of a Namespace ID anywhere.
  • j

    john.spurlock

    08/20/2021, 9:55 PM
    Ah do you mean with
    wrangler
    ? I'm not sure how it maps to the underlying model - I believe it has a concept of environments, perhaps it creates one namespace per env? Not sure. You can always get a list of your DO namespaces with
    GET https://api.cloudflare.com/client/v4/accounts/<account-id>/workers/durable_objects/namespaces
  • w

    Wallacy

    08/20/2021, 10:53 PM
    Anyone knows how to compress a gzip text on Workers? to/and/or Durable Objects? ... I know that i can create a new response and put a gzip content, then call the .text() e get the content decoded . But i dont know to to send a plain text and get a gzip using only the workers. The ideia is store more than the current 32kib of data... I have a 100kb text that can be easy be compressed to 16kib;
  • j

    john.spurlock

    08/20/2021, 10:57 PM
    I don't think it's exposed as a runtime call. It would be cool if CF supported
    CompressionStream
    https://caniuse.com/mdn-api_compressionstream
  • j

    john.spurlock

    08/20/2021, 10:58 PM
    But you'd quickly burn through your CPU limits
  • w

    Wallacy

    08/20/2021, 11:00 PM
    That or the storage.put using some gzip (o other compression) argument.
  • m

    matt

    08/21/2021, 3:48 AM
    yes — you can specify a script name for the binding in
    wrangler.toml
    with wrangler, DO namespaces are an implicit concept instead of being created explicitly — the explicit namespace API that uses namespace ID dates from the private beta, before wrangler had support for DOs
  • m

    mikeysee

    08/21/2021, 5:00 AM
    awesome thanks 🙂
  • m

    mikeysee

    08/21/2021, 6:58 AM
    How do people unit test their durable objects? I have been trying to use some of the helper classes from miniflare (https://github.com/mrbbot/miniflare/blob/2cca9aea04/src/kv/do.ts) but I get the following errors in jest:
    Copy code
    Test suite failed to run
    
        Cannot find module '../generated/offsets' from '../../node_modules/tz-offset/src/tz-offset.js'
    
        Require stack:
          C:/dev/me/tinkering-with-durable-objects/node_modules/tz-offset/src/tz-offset.js
          C:/dev/me/tinkering-with-durable-objects/node_modules/node-cron/src/scheduled-task.js
          C:/dev/me/tinkering-with-durable-objects/node_modules/node-cron/src/node-cron.js
          C:/dev/me/tinkering-with-durable-objects/node_modules/miniflare/dist/index.js
          src/projections/ProjectionDurableObject.test.ts
  • m

    MrBBot

    08/21/2021, 8:37 AM
    are you setting the
    moduleFileExtensions
    Jest option? if you are, make sure you've got
    "json"
    included in that array
  • m

    mikeysee

    08/21/2021, 8:37 AM
    oh lol apparently I was and indeed just adding "json" makes it work 🙂
  • m

    mikeysee

    08/21/2021, 8:37 AM
    thanks!
  • m

    mikeysee

    08/21/2021, 8:38 AM
    BTW @User while I have you, is there a reason
    DurableObjectId
    isnt exported?
  • m

    MrBBot

    08/21/2021, 8:40 AM
    probably just forgot 😆 , you should be able to do
    import { DurableObjectId } from "miniflare/dist/modules/do"
    , the next version will make it much easier to use individual components like this
1...159160161...567Latest