sidekiq

Testing Sidekiq workers using Rspec

守給你的承諾、 提交于 2019-12-24 03:54:06
问题 How do i test the following line of code invokes 'perform' in 5 mins using rspec? CustomSidekiqWorker.perform_in(5.minutes, parameter1) 回答1: If you've set Sidekiq to use inline processing while runnings tests like so: require 'sidekiq/testing' Sidekiq::Testing.inline! Then the following should work in your specs: expect(CustomSideWorker).to receive(:perform_in).with(5.minutes, parameter1) 来源: https://stackoverflow.com/questions/27899120/testing-sidekiq-workers-using-rspec

Use multiple Redis servers in Sidekiq

一笑奈何 提交于 2019-12-24 00:06:06
问题 I am using Sidekiq to process background jobs into one of our Rails project. We want to use a different Redis server located at different location to sepearate out ReportDB with other background processing job. According to Sidekiq config wiki we can configure like config/initializers/sidekiq.rb Sidekiq.configure_server do |config| config.redis = { :url => 'redis://redis.example.com:7372/12', :namespace => 'mynamespace' } end Sidekiq.configure_client do |config| config.redis = { :url =>

Pass file to Active Job / background job

爷,独闯天下 提交于 2019-12-23 17:28:01
问题 I'm receiving a file in a request params through a standard file input def create file = params[:file] upload = Upload.create(file: file, filename: "img.png") end However, for large uploads, I'd like to do this in a background job. Popular background jobs options like Sidekiq or Resque depend on Redis to store the parameters, so I can't just pass a file object through redis. I could use a Tempfile , but on some platforms such as Heroku, local storage is not reliable. What options do I have to

How can I run an ActiveJob in Rails console for debugging?

天涯浪子 提交于 2019-12-23 08:49:39
问题 I currently have an ActiveJob that I've created and use Sidekiq to queue it. I'm wanting to debug the job, but for me to see any messages I program into it I have to check my log files. I feel like it would be more convenient to be able to see my puts messages in my job in the Rails Console. When I run the perform_later method though in rails console it just queues the job up and I never see the messages in console. Is there a way to make it where I will see them in the console? 回答1: You can

Stop sidekiq worker when user logs out

夙愿已清 提交于 2019-12-23 05:22:13
问题 I only want to perform the background job when the user is logged in. When the user is logged in, I start a worker: Warden::Manager.after_authentication do |user,auth,opts| ImapWorker.perform_async(user.id) end All my ImapWorker does is use ruby's Net::Imap API to wait for new emails to come in from a remote email server. It uses Imap's idle functionality to wait for new events. class ImapWorker include Sidekiq::Worker def perform(user_id) user = User.find(user_id) imap = Net::IMAP.new('imap

Reduce the execution time of jobs of sidekiq

大兔子大兔子 提交于 2019-12-22 11:19:03
问题 I am currently working on an app which involves syncing of contacts on rails server. I am using redis server and sidekiq for performing contact syncing in the background. My database is mongodb and I am using mongoid gem as ORM. Workflow is a follows: Contacts on the phone are passed to the rails server through app and then on the rails server, it is queued in the redis server. Now cron job triggers sidekiq which connects to redis and completes the job. One Job of sidekiq is as follows: it

Configuring Puma and Sidekiq

自闭症网瘾萝莉.ら 提交于 2019-12-22 08:06:06
问题 Might be more of trying to overcome a learning curve + actual code question. I apologize if it seems nubish, currently I get this error within production. Basically I keep recieving this "redis pool is too small" and I'm lost where to start, I'm actually lost on basically understanding how to accurately configure sidekiq with puma or anything that comes after configuration like scaling etc. Below I have my configuration followed my error I recieve . ProcFile web: bundle exec puma -C config

How to share worker among two different applications on heroku?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 02:19:49
问题 I have two separate applications running on heroku and pointing to same database, first one responsible for user interface and second one for admin interface , I am using sidekiq with redis for background job processing, I have added one worker and I am able to share 'redis-server' by setting environment variable pointing to same Redis providing Addon, Now i wish to share worker too, because adding the extra worker will cost double. Please suggest, whether this is even possible or not? 回答1:

Colon in the front: YAML syntax

一曲冷凌霜 提交于 2019-12-20 17:43:09
问题 I'm currently using Sidekiq in a project and I have the following YAML config file: :concurrency: 5 :pidfile: /tmp/pids/sidekiq.pid :logfile: log/sidekiq.log staging: :concurrency: 10 production: :concurrency: 20 queues: - default I haven't seen having a colon in front of a key before but omitting that colon produces interesting results. In the case of the :pidfile: for example, with the colon in front it creates/overrides the destination file where is without it, it uses the one already

Sidekiq Rails 4.2 Use Active Job or Worker? What's the difference

怎甘沉沦 提交于 2019-12-20 08:40:58
问题 This is my first processing jobs asynchronously I am implementing Sidekiq for background processing in my app. I will use it for reminder emails and in-app notifications. I am confused as to whether I should use Active Job to create a job that sends an email or a Sidekiq Worker to send an email. They seem to do the same thing and Rails 4.2 Active Job seems very new…is it replacing the need for a Sidekiq Worker? Below is the same sending a mailer code using an Active Job job and a Sidekiq