You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to improve some api response, by resolve them, I using parallel gem.
And I faced one problem about the way of reconnection.
I used ActiveRecord::Base.connection.reconnect! but It is Not working and it is reason DB is connection away
My db composition is 1 primary and 4 replica
below is sample of my source-code and it is working.
I would like need the way that more simply and flexible portion of reconnect
def search_by_keyword
resulted_search = Parallel.map(search_keywords, in_processes: 4) do |keyword|
reconnection
request_third_party_to_get_search → heavy logic
end
reconnection
end
def reconnection
ActiveRecord::Base.using(:replica1).connection.reconnect!
ActiveRecord::Base.using(:replica2).connection.reconnect!
ActiveRecord::Base.using(:replica3).connection.reconnect!
ActiveRecord::Base.using(:replica4).connection.reconnect!
ActiveRecord::Base.using(:master).connection.reconnect!
end
The text was updated successfully, but these errors were encountered:
Thank you for your answer
I also couldn't find out it.
So I just used the roop
(1..4).each do |no|
replica_name = "replica{no}".to_sym
ActiveRecord::Base.using(replica_name).connection.reconnect!
end
ActiveRecord::Base.using(:master).connection.reconnect!
I try to improve some api response, by resolve them, I using parallel gem.
And I faced one problem about the way of reconnection.
I used
ActiveRecord::Base.connection.reconnect!
but It is Not working and it is reason DB is connection awayMy db composition is 1 primary and 4 replica
below is sample of my source-code and it is working.
I would like need the way that more simply and flexible portion of reconnect
The text was updated successfully, but these errors were encountered: