#Get task by ID

1 messages · Page 1 of 1 (latest)

summer edge
#

Hi there,

We are trying to understand how to retrieve a task by the run ID. What we need to do is check if a task is already running in order to prevent multiple executions.

If this is not currently available, any strategy to retrieve tasks (such as by date, status, or any other parameter) could be helpful.

gilded tangle
#

Do you mean through an API call?

#

You can use an idempotency key to prevent duplicate runs from happening, which might be a better solution

summer edge
#

That could actually be useful, but I'm not sure what to use as a key.

What we did is the following:
We have a Nuxt server that exposes trigger tasks as an endpoint.
The two runs that we want to prevent from being executed simultaneously are a file import and a massive Algolia reindex. The point is that I don't believe I have something readily usable as an idempotency key to prevent duplicate runs because duplicate runs should actually be a possibility.

Currently, we are limiting the concurrency to one run, so that other hits to the endpoint just queue up other runs.

gilded tangle
#

The other thing you could do (which might be better) is to create a single task that calls those "file import" and "algolia reindex" tasks

#

With triggerAndWait

#

Then you could trigger that "parent" task from the Nuxt endpoint. And the parent task could have a concurrency of 1