Skip to content

Commit

Permalink
Merge pull request #44 from jstenhouse/main
Browse files Browse the repository at this point in the history
  • Loading branch information
miyataka authored Apr 21, 2024
2 parents 62fbdbf + 6543089 commit befb345
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ Fcmpush.configure do |config|
# config.proxy = { uri: "http://proxy.host:3128", user: nil, password: nil }
# explicitly disable using proxy, even ignore environment variables if set
# config.proxy = false

# HTTP connection open and read timeouts (in seconds) are set for all client requests.
# If unset, the default values for Net::HTTP::Persistent are used (currently 60 seconds).
# config.open_timeout = 30
# config.read_timeout = 15
end
```

Expand Down
3 changes: 3 additions & 0 deletions lib/fcmpush/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def initialize(domain, project_id, configuration, **options)
# @server_key = configuration.server_key
@connection = Net::HTTP::Persistent.new

@connection.open_timeout = configuration.open_timeout if configuration.open_timeout
@connection.read_timeout = configuration.read_timeout if configuration.read_timeout

if !configuration.proxy
# do nothing
elsif configuration.proxy == :ENV
Expand Down
6 changes: 5 additions & 1 deletion lib/fcmpush/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module Fcmpush
class Configuration
attr_accessor :scope, :json_key_io, :server_key, :proxy
attr_accessor :scope, :json_key_io, :server_key, :proxy, :open_timeout, :read_timeout

def initialize
@scope = ['https://www.googleapis.com/auth/firebase.messaging']
Expand All @@ -26,6 +26,10 @@ def initialize
# cf. https://github.com/miyataka/fcmpush/pull/39#issuecomment-1722533622
# proxy
@proxy = :ENV

# connection timeouts
@open_timeout = nil
@read_timeout = nil
end
end
end

0 comments on commit befb345

Please sign in to comment.