This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class InvoiceChargeBatchWorker | |
| include TResque::Worker | |
| worker_lock :all | |
| queue_lock :all | |
| def work | |
| Invoice.where(stat: 'pending').find_each do |invoice| | |
| InvoiceChargeWorker.enqueue(invoice_id: invoice.id) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class InvoiceChargeWorker | |
| include TResque::Worker | |
| inputs :invoice_id | |
| worker_lock :invoice_id | |
| def work | |
| return unless needed? | |
| invoice.charge! | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'resque/tasks' | |
| require 'resque_scheduler/tasks' | |
| require "resque_bus/tasks" | |
| namespace :resque do | |
| task :setup => [:environment] do | |
| require 'resque_scheduler' | |
| require 'resque/scheduler' | |
| require 'tresque' | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'tresque' | |
| module Account | |
| class RegularWorker | |
| include ::TResque::Worker | |
| # defaults to account_default queue | |
| end | |
| end | |
| module Account |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| subscribe "user_changed" do |attributes| | |
| UserIndexWorker.enqueue(user_id: attributes['id']) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class InvoiceChargeWorker | |
| include TResque::Worker | |
| inputs :invoice_id | |
| worker_lock :to_id | |
| def work | |
| return unless needed? | |
| invoice.charge! | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UserIndexWorker | |
| include TResque::Worker | |
| inputs :user_id | |
| queue_lock :user_id | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class InvoiceChargeWorker | |
| include TResque::Worker | |
| inputs :invoice_id | |
| def work | |
| return unless needed? | |
| invoice.charge! | |
| end | |
| def needed? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UserIndexWorker | |
| include TResque::Worker | |
| inputs :user_id | |
| def work | |
| Elasticsearch.index('users').write(user.attributes.slice(:id, :first_name, :last_name, :etc)) | |
| end | |
| def user | |
| @user ||= User.find(user_id) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class UserIndexWorker | |
| include TResque::Worker | |
| inputs :id, :first_name, :last_name, :etc | |
| def work | |
| Elasticsearch.index('users').write(id, id: id, first_name: first_name, last_name: last_name, etc: etc) | |
| end | |
| end | |
| # When user changes |