Created
September 28, 2019 14:40
-
-
Save sat0yu/22676846bf8b6125afadb08f956844cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveRecordWithConnectionInterceptor < ::GRPC::ServerInterceptor | |
def request_response(**) | |
# ref: https://github.com/rails/rails/blob/5-2-stable/activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb#L54-L56 | |
::ActiveRecord::Base.connection_pool.with_connection do | |
yield | |
end | |
end | |
alias_method :server_streamer, :request_response | |
alias_method :client_streamer, :request_response | |
alias_method :bidi_streamer, :request_response | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment