0
0
Fork 0

Change notifications API to use a replica (#25874)

This commit is contained in:
Eugen Rochko 2023-07-12 17:06:00 +02:00 committed by GitHub
parent 82e477b184
commit fdc3ff7c2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 31 additions and 11 deletions

View file

@ -3,14 +3,15 @@
class MergeWorker
include Sidekiq::Worker
include Redisable
include DatabaseHelper
def perform(from_account_id, into_account_id)
ApplicationRecord.connected_to(role: :primary) do
with_primary do
@from_account = Account.find(from_account_id)
@into_account = Account.find(into_account_id)
end
ApplicationRecord.connected_to(role: :read, prevent_writes: true) do
with_read_replica do
FeedManager.instance.merge_into_home(@from_account, @into_account)
end
rescue ActiveRecord::RecordNotFound