Call the notify user job from the controller, instead of calling the user notifier directly.(you can use rails generate job, per the ActiveJob docs) To simulate the pain of waiting for synchronous jobs, when you use this app, the “send email” method has a five-second sleep in it. The essence of a background job is to do stuff in the background, without making the Rails app sit around doing all the work. Redis isn’t doing anything Convert a non-background-job to a background job I’ll recap most of what’s in the tutorial. This is what my repo looks like right now. If you want to follow along, do the above tutorial. So, this post will focus not as much on using Sidekiq, but seeing that it’s working. I very much enjoy seeing evidence of things working “under the hood”, rather than just accepting that BackgroundWorker.perform_later(foo.id) works differently than (foo.id), etc. In this case, I went back to Turing! I found the background jobs lesson from Mod 3, and worked through it. Medium won’t let me set anchor tags, so I cannot link to this section. ![]() Most of the interesting stuff is way down at the bottom, in the section titled Watching Redis. And I got dropped into a project that has dozens of jobs, handling hundreds of thousands of actions a day.Īs is my style, when I don’t understand something, I like to go to the very basics. The reason I needed such basic overviews is because prior to my current job, I’d had just a few hours of exposure to background jobs, and understood little of those hours. ![]() Anyone who knows much at all about Sidekiq will say “oh, duh, of course that’s true”, but at the time, it wasn’t obvious to me. I’ve recently had to learn more about background jobs (using Sidekiq, specifically) for some bugs I was working on. Add comments there, and follow via email for more updates when they happen! I’ve got this cross-posted and slightly updated on /sidekiq-and-background-jobs-in-rails-for-beginners. Sidekiq and Background Jobs for Beginners
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |