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

[Feature Request] Minion Backend list_jobs: using args as search filter #91

Open
atoomic opened this issue Jan 9, 2020 · 5 comments
Open

Comments

@atoomic
Copy link

atoomic commented Jan 9, 2020

list_jobs allow to filter on @$options{qw(ids notes queues states tasks)}
but this would be a great addition to be able to filter on args

Simple use case:

  • avoiding duplicate pending jobs in the queue [using a guard]

Workaround using a note... which can be used in the search.
Otherwise will have to look for every inactive jobs...

 my $mykey = join '_', @$args;
 my $guard_key = $mykey;
 my $guard = $minion->guard( $guard_key, $timeout );
 my $search = $minion->backend->list_jobs( 0, 1, { 
    notes => [ $mykey ], # workaround
    states => [ 'inactive' ] 
    } );

# already a pending job for this same task, avoid adding one... 
return if $search && $search->{total}; 
my $id = $minion->enqueue( something => $args, { notes => { $mykey => 1 } } );
@kraih
Copy link
Member

kraih commented Jan 9, 2020

Problem is performance, since args are arbitrary data structures i don't see how they could ever be searched efficiently.

@arhak
Copy link

arhak commented May 4, 2020

It doesn't have to be the $args itself
Same $mykey as in the given example may have a better placement than notes key

Many use cases would take advantage of identifying an instance of a task performed onto a given object

While reducing a queue of items, knowing that a job has been already queued for a given item->id would be handy

@rabbiveesh
Copy link

You can already work around this if you know that you need to search it by putting the id you're interested in also into notes. I'm fairly certain that's what we concluded last time I brought this up on IRC

@kraih
Copy link
Member

kraih commented Jun 1, 2020

Yes, i believe we already have the best possible solution for this problem implemented with indexed notes keys. There is nothing more for us to do.

@kraih
Copy link
Member

kraih commented Aug 3, 2020

Having a slow search option with an args like '%foo%' search is still a possibility, since it would be rather useful for the admin ui.

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

No branches or pull requests

4 participants