The code powering m.abunchtell.com https://m.abunchtell.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

18 lines
409 B

  1. # frozen_string_literal: true
  2. class DistributionWorker
  3. include Sidekiq::Worker
  4. def perform(status_id)
  5. RedisLock.acquire(redis: Redis.current, key: "distribute:#{status_id}") do |lock|
  6. if lock.acquired?
  7. FanOutOnWriteService.new.call(Status.find(status_id))
  8. else
  9. raise Mastodon::RaceConditionError
  10. end
  11. end
  12. rescue ActiveRecord::RecordNotFound
  13. true
  14. end
  15. end