Hi, I have a usecase, where a web server is deployed on a Google Cloud run service that listens to HTTP requests.
Upon receiving certain requests to perform some long-running task, the service puts the requests in the database and then it needs to start the long-running process.
I don’t need to keep the service up and running indefinitely and without setting minimum idle instances my service instance will be deleted if it does not receive a request for 15 minutes, even if my long-running task is being performed in the background.
Using a Google Cloud run job seemed a good option here, but I was unable to find how to send some parameters while executing the deployed job.
I did see this, but I couldn’t find how to achieve this via some client library like node js.
The main HTTP server will listen to requests and upon receiving one, it will dump basic info in the database and then will call the job with the id of the recently dumped request.
As an alternative what I am doing for now is instead of sending the ID to the job while invoking it via the client SDK, I simply invoke, and in the job, I get the latest request with a certain status while locking the row and instantly updating the status of that request so in case of parallel job executions a same row is not returned to more than 1 jobs.
I was using the 1.0.1 version of google-cloud/run npm package, the latest version when I posted here.
Now I can see a newer version 1.0.2 that was published approximately 16 hours ago (2023-10-18 17:46:52 UTC), this does have the overrides attribute for the request in it.
It should be; the only thing is, the Cloud Scheduler trigger takes a fixed URL that doesn’t change between invocations, so you’ll be passing the same argument each time / overriding the the arguments with the same value each time. Does that make sense?
Let me know if that’s how you’re using it (same argument values each time) and find that it’s not working.
Looks like the overrides go in the request body. You can configure that in the Cloud Scheduler UI. (I don’t think the Cloud Run Triggers tab lets you configure the request body, but the Cloud Scheduler UI does.)