https://discord.cloudflare.com logo
Join Discord
Powered by
# workers-discussions
  • c

    Chaika

    05/17/2023, 2:51 PM
    they already have: https://blog.cloudflare.com/workers-tcp-socket-api-connect-databases/
  • b

    boywithkeyboard

    05/17/2023, 2:52 PM
    oh bruh, didn't notice that there was a
    cloudflare:sockets
    package XD
  • b

    boywithkeyboard

    05/17/2023, 2:53 PM
    so i can use mongodb atlas over tcp from workers?
  • u

    Unsmart | Tech debt

    05/17/2023, 2:54 PM
    Would probably be a pain to get working because im not aware of any lib that uses cloudflare sockets for it but yes you can
  • b

    boywithkeyboard

    05/17/2023, 2:57 PM
    @Chaika wait... is this closed beta?
  • c

    Chaika

    05/17/2023, 2:58 PM
    No, "The TCP Socket API is available today to everyone."
  • b

    boywithkeyboard

    05/17/2023, 3:02 PM
    there's already a mongodb client for deno, i'm trying to port it over and probably post it in #783765338692386886 later
  • b

    boywithkeyboard

    05/17/2023, 3:08 PM
    the design decision with importing it from
    cloudflare:sockets
    is a bit questionable
  • b

    boywithkeyboard

    05/17/2023, 3:09 PM
    a global variable would've been probably the better choice
  • u

    Unsmart | Tech debt

    05/17/2023, 3:11 PM
    I think its like that because theres no standard for TCP sockets yet
  • b

    boywithkeyboard

    05/17/2023, 3:12 PM
    are there type declarations for it?
  • n

    nora

    05/17/2023, 3:20 PM
    I can't imagine it would be efficient to ship it with every single deployment ever, if it's never used
  • b

    boywithkeyboard

    05/17/2023, 3:22 PM
    you could still analyze the code to check whether the global variable is used
  • n

    nora

    05/17/2023, 3:22 PM
    of course, but an import would imo be the more "proper" way :D
  • b

    boywithkeyboard

    05/17/2023, 3:23 PM
    if there's no type support - as it looks like - it's pretty stupid
  • b

    boywithkeyboard

    05/17/2023, 3:23 PM
    it's also annoying if you use deno for development tbh
  • b

    boywithkeyboard

    05/17/2023, 3:24 PM
    if there was a global variable, e.g.
    Cloudflare
    , you could just add the type to the
    workers-types
    package
  • b

    boywithkeyboard

    05/17/2023, 3:25 PM
    i'm not saying that this feature is bad - it was actually the one feature i waited for all along - but i just don't like its implementation plus i hope that some mongodb client out there will adopt it soon
  • n

    nora

    05/17/2023, 3:25 PM
    I'm sure they'll come with a lib type declaration soon enough
  • d

    Dani Foldi

    05/17/2023, 3:26 PM
    indeed, the next release of workers-types will already contain the types for
    cloudflare:sockets
    , PR is already merged, so just keep an eye on npm/github!
  • h

    HardAtWork

    05/17/2023, 3:28 PM
    The import was used explicitly to demonstrate that this is a platform-locked API, and not something that is cross-compatible with other runtimes. If/when a standard develops, I assume they would add support for it as a global
  • b

    boywithkeyboard

    05/17/2023, 3:29 PM
    i mean if you look at e.g. deno, they use the global
    Deno
    variable for such features
  • h

    HardAtWork

    05/17/2023, 3:29 PM
    Guess it is just a platform-based choice then?
  • b

    boywithkeyboard

    05/17/2023, 3:29 PM
    yeah
  • b

    boywithkeyboard

    05/17/2023, 3:30 PM
    is there any known mongodb client out there which supports it already?
  • i

    Isaac McFadyen | YYZ01

    05/17/2023, 5:18 PM
    Analyzing code is hard, and just adds complexity for something that's not really needed (i.e. the import works).
  • i

    Isaac McFadyen | YYZ01

    05/17/2023, 5:19 PM
    Also the way the runtime (
    workerd
    ) works, the more global things that are added at runtime the longer the startup time for customers that don't use them - that's why bindings are now available through a variable instead of the global scope.
  • f

    frydim1

    05/17/2023, 5:19 PM
    This says traffic goes by a page rule before getting to a worker

    https://cdn.discordapp.com/attachments/779390076219686943/1108443746984542298/image.png▾

  • f

    frydim1

    05/17/2023, 5:20 PM
    so why a cache hit by a page rule generates a billed worker request ?
  • f

    frydim1

    05/17/2023, 5:20 PM
    i.e if i page the results of a worker with a page rule, and the next requests are a cache hit will i pay for a request to the worker again? or i'm understanding it wrong ?
1...247124722473...2509Latest