Change notifications API to use a replica (#25874)
This commit is contained in:
parent
82e477b184
commit
fdc3ff7c2d
8 changed files with 31 additions and 11 deletions
|
@ -2,9 +2,10 @@
|
|||
|
||||
class FeedInsertWorker
|
||||
include Sidekiq::Worker
|
||||
include DatabaseHelper
|
||||
|
||||
def perform(status_id, id, type = 'home', options = {})
|
||||
ApplicationRecord.connected_to(role: :primary) do
|
||||
with_primary do
|
||||
@type = type.to_sym
|
||||
@status = Status.find(status_id)
|
||||
@options = options.symbolize_keys
|
||||
|
@ -18,7 +19,7 @@ class FeedInsertWorker
|
|||
end
|
||||
end
|
||||
|
||||
ApplicationRecord.connected_to(role: :read, prevent_writes: true) do
|
||||
with_read_replica do
|
||||
check_and_insert
|
||||
end
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue