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

    Neiki

    05/14/2023, 12:36 PM
    can i do let my worker run for 5 minutes f.ex with "waitUntil" and a promise timeout that resolve after 5 minutes or 4 minutes? (currently i have free plan if that is important), after that 5 minutes it would fetch something and send response
  • r

    Razvan

    05/14/2023, 12:37 PM
    thats called cron job
  • n

    Neiki

    05/14/2023, 12:44 PM
    ah thanks!
  • s

    sathoro

    05/14/2023, 1:14 PM
    use alarms in Durable Objects
  • a

    AA

    05/14/2023, 6:39 PM
    whats the recommended way for connecting to a postgres db from a worker? cloudflare seems to have articles pointing lots of different ways.. and i also see the neon stuff
  • t

    Tom Sherman

    05/14/2023, 7:10 PM
    atm you'll need to connect over HTTP somehow
  • j

    James

    05/14/2023, 7:10 PM
    Stuff might be coming soon đź‘€ https://twitter.com/CherryJimbo/status/1654505957316018177
  • a

    AA

    05/14/2023, 7:11 PM
    wow, my exact need.
  • a

    AA

    05/14/2023, 7:12 PM
    i've always found myself needing things 3-6 months ahead of when cloudflare is releasing something :/
  • t

    Tom Sherman

    05/14/2023, 7:12 PM
    i wonder how connection pooling will work there
  • t

    Tom Sherman

    05/14/2023, 7:13 PM
    gonna need a DO for that?
  • a

    AA

    05/14/2023, 7:16 PM
    yea i've wondered about that myself for any db connection from a worker
  • k

    kian

    05/14/2023, 7:17 PM
    iirc you can do it in a DO
  • s

    sathoro

    05/14/2023, 7:23 PM
    personally I'd setup pgbouncer and use that
  • a

    AA

    05/14/2023, 7:28 PM
    https://blog.cloudflare.com/neon-postgres-database-from-workers/ states
    Even when Workers eventually support raw TCP communication, we will not have fully solved our problem, because database connections are expensive to set up and also have quite a bit of memory overhead.
  • s

    Skye

    05/14/2023, 7:30 PM
    A DO would solve that, since you save the connection between requests to it, and it'll keep it around for a while after each request
  • s

    sathoro

    05/14/2023, 7:39 PM
    not fully solved though at least not without building a lot of connection pool logic. for example you don't want only a single connection, you would want multiple and you also would want a different number of db connections and client connections, etc. and this is just the tip of iceberg
  • s

    Skye

    05/14/2023, 7:40 PM
    The majority of users would get by completely fine on one lol
  • s

    sathoro

    05/14/2023, 7:43 PM
    1 single connection? I dunno... it would work fine until very suddenly it doesn't and then you'd be asking yourself why you didn't just setup a proper connection pooler while your app is down in production and you are scrambling
  • a

    AA

    05/14/2023, 7:43 PM
    pgbounce sounds better
  • a

    AA

    05/14/2023, 7:44 PM
    the mystery for me is the word "soon" if this is out in a month i'll hold off. if its 6 months. i'll need another solution
  • s

    sathoro

    05/14/2023, 7:45 PM
    do you already have a postgres db? because one option is to use Supabase. you get a dedicated Postgres db and can use their HTTP APIs (this is what we do)
  • s

    sathoro

    05/14/2023, 7:47 PM
    we try to call Supabase directly from the client (browser) as much as possible but in a couple situations we call it from in a Worker and it is easy to do
  • a

    AA

    05/14/2023, 7:47 PM
    yea i already have a postgresdb. I can just host the webhooks somewhere else. but i wanted to use cloudflare
  • s

    sathoro

    05/14/2023, 7:49 PM
    another option is putting PostgREST in front of your db
  • a

    AA

    05/14/2023, 7:49 PM
    yea i saw some cloudflare docs recommending that as well
  • s

    sathoro

    05/14/2023, 7:49 PM
    actually I think Supabase uses this
  • s

    sathoro

    05/14/2023, 7:49 PM
    it has built in connection pooler
  • s

    sathoro

    05/14/2023, 7:50 PM
    so might as well do that since you'd have to setup a connection pooler anyways...
  • a

    AA

    05/14/2023, 7:51 PM
    supabase does look interesting, seems like it can be selfhosted as well
1...245924602461...2509Latest