Skip to content

Commit

Permalink
Merge pull request #37 from vadshalamov/master
Browse files Browse the repository at this point in the history
feature: move recreate_queues task from blizko
  • Loading branch information
artofhuman authored Feb 16, 2017
2 parents 3940f5c + fb5f5a9 commit c6ae751
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/models/treasury/models/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,15 @@ def pgq_queue_name
"q_#{name}"
end

# Public: Пересоздает очередь, триггер и переподписывает связанные
# обработчики.
#
# Returns nothing.
def recreate!
destroy_pgq_queue
processors.each(&:subscribe!)
end

protected

def lock_table!
Expand Down
5 changes: 5 additions & 0 deletions lib/tasks/treasury.rake
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,10 @@ namespace :treasury do
task drop_triggers: :environment do
Apress::Utils::Triggers.drop_triggers(:trigger_pattern => "#{Treasury::Models::Queue::TRIGGER_PREFIX}*")
end

desc 'Пересоздает очереди, триггеры и подписки для всех процессоров'
task recreate_queues: :environment do
Treasury::Models::Queue.all.each(&:recreate!)
end
end
end
2 changes: 2 additions & 0 deletions lib/treasury/backwards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ module Redis
end

ROOT_REDIS_KEY = ::Treasury::ROOT_REDIS_KEY
ROOT_LOGGER_DIR = ::Treasury::ROOT_LOGGER_DIR
ReinitializeObjectJob = ::Treasury::ReinitializeObjectJob
end

Expand Down Expand Up @@ -131,6 +132,7 @@ module Redis
end

ROOT_REDIS_KEY = ::Treasury::ROOT_REDIS_KEY
ROOT_LOGGER_DIR = ::Treasury::ROOT_LOGGER_DIR
end

Pgq = ::Treasury::Pgq

0 comments on commit c6ae751

Please sign in to comment.