Background jobs Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

How to generate a new background job?

A

rails g job job_name

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does a job file include?

A
class NameJob < ApplicationJob
  queue_as :default

def perform(*args)
# Do something later
end
end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to run the job? ( 2 ways )

A

NameJob.perform_now

NameJob.perform_later

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the difference between sidekiq worker and rails job?

A

Short answer is they are the same thing. ActiveJob calls it a Job whereas Sidekiq calls it a Worker. I’ve decided to keep the terminology different so that people can distinguish the two.

You can use either one. Note that ActiveJob does not provide access to the full set of Sidekiq options so if you want to customize options for your job you might need to make it a Worker.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What queuing backend tools do you know?

A
  • Sidekiq
  • Rescue
  • DelayedJob
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to clear all Sidekiq queries?

A

Sidekiq::Queue.all.each {|q| q.clear}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly