Skip to content

Commit

Permalink
feat: add connection pooling and idle timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdeme committed Jan 26, 2022
1 parent 8f9d844 commit 9e58dff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/stream-chat/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require 'open-uri'
require 'faraday'
require 'faraday/multipart'
require 'faraday/net_http_persistent'
require 'jwt'
require 'time'
require 'stream-chat/channel'
Expand Down Expand Up @@ -46,7 +47,10 @@ def initialize(api_key = '', api_secret = '', timeout = 6.0, **options)
faraday.options[:open_timeout] = @timeout
faraday.options[:timeout] = @timeout
faraday.request :multipart
faraday.adapter :net_http
faraday.adapter :net_http_persistent, pool_size: 5 do |http|
# AWS load balancer idle timeout is 60 secs, so let's make it 59
http.idle_timeout = 59
end
end
end

Expand Down
2 changes: 2 additions & 0 deletions stream-chat.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Gem::Specification.new do |gem|

gem.add_dependency 'faraday'
gem.add_dependency 'faraday-multipart'
gem.add_dependency 'faraday-net_http_persistent'
gem.add_dependency 'net-http-persistent'
gem.add_dependency 'jwt'
gem.add_development_dependency 'rake'
gem.add_development_dependency 'rspec'
Expand Down

0 comments on commit 9e58dff

Please sign in to comment.