简体   繁体   中英

Rails: NameError: uninitialized constant Sidekiq::RetrySet

I am using Sidekiq in one of my projects. Now I need to clear a queue, the RetrySet , to be more specific.

Following this page from Sidekiq's Github manual, this should work:

Loading development environment (Rails 4.2.1)
>> Sidekiq::RetrySet.new.clear
NameError: uninitialized constant Sidekiq::RetrySet

But it doesn't. Sidekiq itself seems to be loaded:

>> Sidekiq
=> Sidekiq

What am I doing wrong here?

EDIT:

Using Sidekiq version 3.3.4

Looks like you need to require the api library explicitly.

require 'sidekiq/api'

See this for more info https://github.com/mperham/sidekiq/issues/1732

See https://github.com/mperham/sidekiq/blob/master/lib/sidekiq/api.rb#L612

The inheritance explaination

class SortedSet
 ...

 def clear
 ...
 end
end

class JobSet < SortedSet
  ...
end

class RetrySet < JobSet
  ...
end

However, In my rails console it worked without needing me to require the library. It was already required. see

> require 'sidekiq/api'
=> false

I use Sidekiq 4.0.1

> Sidekiq::VERSION
=> "4.0.1"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM