contribsys / faktory_worker_ruby

Faktory worker for Ruby
GNU Lesser General Public License v3.0
214 stars 31 forks source link

Unique jobs do not work with ActiveJob #56

Open lucasteligioridis opened 3 years ago

lucasteligioridis commented 3 years ago

Trying to do the below task in order to create unique jobs, as per: https://github.com/contribsys/faktory/wiki/Pro-Unique-Jobs

My job classes look something like:

class FaktoryJob < ActiveJob::Base
  self.queue_adapter = :faktory
  queue_as 'default'
end

class SleepJob < FaktoryJob
  faktory_options custom: { unique_for: 5 }

  def perform
    sleep 10.seconds
  end
end

It seems that there might be an issue with the custom object being passed in correctly utilising ActiveJob vs native Faktory::Jobs As you can see two identical jobs are enqueued immediately after one another:

Screen Shot 2021-04-12 at 8 41 48 am

mperham commented 3 years ago

I've updated the wiki page to note that uniqueness does not work with the ActiveJob wrapper.

lucasteligioridis commented 3 years ago

Is there any plans to support this? We're kind of relying on this feature in our stack.

mperham commented 3 years ago

Can you use Faktory::Job? It has the exact same perform_later API.

lucasteligioridis commented 3 years ago

I'll speak to the team in regards to this, we were just hoping for a happy plug and play moment. Might be okay to just use Faktory::Job directly in this case though.

mperham commented 3 years ago

Unfortunately the fix is not easy. I will keep this open.

lucasteligioridis commented 3 years ago

No problem 👍🏼 Thanks mate :)