#backend decision suggestion

1 messages · Page 1 of 1 (latest)

nova belfry
#

i know convex is a full backend, but i have a script written in golang, i would like to use convex as my database for my app, and have it queue background jobs to the script i wrote. whats the best way to "connect" convex with my golang script? maybe use actions, to add job to redis queue, then read redis queue from golang and then call convex api via http inside my golang code? suggest me

lost kayakBOT
#

Hi @nova belfry. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Yes, you're on the right track! Convex can indeed be used as your database and to queue background jobs. Here's a suggested approach based on the information from the knowledge sources:

  1. Use Convex as your database: Convex provides a global state management system that runs in the cloud, making it easy to build interactive and collaborative applications. You can use Convex's built-in primitives to manage your data. Remember, Convex is "just code", so you can solve composition and encapsulation problems in your server-side Convex code using the same methods you use for the rest of your TypeScript code bases (source (https://docs.convex.dev/zen)).

  2. Queue background jobs using actions: Convex's actions are powerful and can be used to trigger background jobs. However, it's important to be intentional in how they fit into your app's data flow. In general, it's an anti-pattern to call actions from the browser. Usually, actions are running on some dependent record that should be living in a Convex table. So it's best to trigger actions by invoking a mutation that both writes that dependent record and schedules the subsequent action to run in the background (source (https://docs.convex.dev/zen)).

  3. Connect Convex with your Golang script: While Convex doesn't have explicit support for Golang, you can generate OpenAPI specifications from your Convex deployment to create type-safe clients for languages that aren't currently supported. This uses Convex's HTTP API, meaning your queries will not be reactive/real-time. You can use this to connect Convex with your Golang script (source (https://docs.convex.dev/client/open-api)).

#
  1. Use Redis for job queueing: While the knowledge sources don't provide specific information about using Redis with Convex, your idea of using actions to add jobs to a Redis queue, and then reading the Redis queue from your Golang script seems feasible. You can then call the Convex API via HTTP inside your Golang code.

Remember, Convex is designed to be your entire backend, so you should be able to program your backend to fit your specific needs. If there's some missing core functionality in Convex, you can let the Convex team know (source (https://stack.convex.dev/cron-jobs#the-power-is-yours)).

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: