Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API for accessing in_progress jobs #119

Open
lguminski opened this issue Jul 17, 2021 · 0 comments
Open

API for accessing in_progress jobs #119

lguminski opened this issue Jul 17, 2021 · 0 comments

Comments

@lguminski
Copy link

lguminski commented Jul 17, 2021

For my use case, before placing a new job in the queue, I want to check if I am not duplicating work. So I would need to check if a job with the same parameters is already in the queue or being processed.

Honeydew.filter/2 allows me to search for jobs is the queue, but I realized that there is no API for finding jobs in progress. I can dig out this information out of data returned by Honeydew.status/2

Honeydew.status(:my_queue)
  |> Map.get(:workers)
  |> Enum.reduce([], fn {_k, v}, acc -> if not is_nil(v), do: [elem(v, 0)  | acc], else: acc end)

or straight from Mnesia, which I am using as a backend

:mnesia.activity(:async_dirty, fn -> :mnesia.foldl(fn wrapped_job_record, list -> [elem(wrapped_job_record, 2) | list] end, [], :"honeydew_:my_queue_in_progress") end)

but it is unstable because any change in the structure of the data can break my code, and this worries me.

I would appreciate having an official API for getting "in progress" jobs (in this sense the request is related to #96).

PS. I am thinking that perhaps the simplest solution would be just updating Honeydew.filter/2, so that its result includes "in progress" jobs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant