usps-imis-api 0.14.1 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92f296666b675bed596644db341453658848f8ff2fff5484a44092627f32e0bf
4
- data.tar.gz: 369f09117790760fed0f5c9166753626a0ef3e02a75525cdd6346df5779e782c
3
+ metadata.gz: 3b20172987ecd5b1bd13b0f142b616d71704e906aed312d71dca5e9b63c8432c
4
+ data.tar.gz: aab0fa56ded131c2a116203ea292c15ab024d408309a03144aeb5e795df77820
5
5
  SHA512:
6
- metadata.gz: 89af34efab0e554f3a4c0091ffca5bdf6b972fdd13b8e1b62e73e894a0fe83adba858a4a4bf2b25756f4d4c5e7fa909ef8601b53f0976163c1179a1873ed22b6
7
- data.tar.gz: 56c89598f8a3b53fbbc697b96855c45af807318a80f180727e7354e3c4de246903ebd03a87da9c6ca2624fdbcd7d244901c03a739000cd37f7d062b41d6cfc0a
6
+ metadata.gz: 108e95c1487b42e6cf8508705e286094b1b79f7c2b3a10feb5bbf818d926837c1f5ca0f35e1f1bfc08b3a9a3a00e8e09f1b734dcde32e7995aa012ffceb78841
7
+ data.tar.gz: b42d7b63f8a0131003d8bb86cd4b2abc25e28842b6d79f9af01d426cd5dedbe64f81afa727b13658349b618a18203c5d60e88989528b3dc2cd1fb761a6ccebae
data/lib/usps/imis/api.rb CHANGED
@@ -264,13 +264,14 @@ module Usps
264
264
  def http_connection
265
265
  return @http_connection if @http_connection&.started?
266
266
 
267
- hostname = URI(Imis.configuration.hostname)
267
+ config = Imis.configuration
268
+ hostname = URI(config.hostname)
268
269
  @http_connection = Net::HTTP.new(hostname.host, hostname.port).tap do |http|
269
270
  http.use_ssl = true
270
271
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
271
- http.open_timeout = 10
272
- http.read_timeout = 30
273
- http.write_timeout = 30
272
+ http.open_timeout = config.open_timeout
273
+ http.read_timeout = config.read_timeout
274
+ http.write_timeout = config.write_timeout
274
275
  http.keep_alive_timeout = 30
275
276
  http.start
276
277
  end
@@ -10,8 +10,19 @@ module Usps
10
10
  IMIS_ROOT_URL_PROD = 'https://portal.americasboatingclub.org'
11
11
  IMIS_ROOT_URL_DEV = 'https://abcdev.imiscloud.com'
12
12
  DEFAULT_GLOBAL_LOG_PATH = '/var/log/imis/imis.log'
13
+
14
+ # Net::HTTP timeouts for the API connection (seconds). open_timeout governs connection
15
+ # establishment (TCP connect + TLS handshake) — the phase that stalls when iMIS is unreachable,
16
+ # so it defaults low to fail fast rather than pin the caller.
17
+ DEFAULT_OPEN_TIMEOUT = 3
18
+ DEFAULT_READ_TIMEOUT = 30
19
+ DEFAULT_WRITE_TIMEOUT = 30
20
+
13
21
  REQUIRED = %w[username password].freeze
14
- OPTIONAL = %w[environment logger_file global_log_path pretty_print_api].freeze
22
+ OPTIONAL = %w[
23
+ environment logger_file global_log_path pretty_print_api
24
+ open_timeout read_timeout write_timeout
25
+ ].freeze
15
26
  SETTABLE = (REQUIRED + OPTIONAL).freeze
16
27
 
17
28
  class << self
@@ -24,13 +35,16 @@ module Usps
24
35
  end
25
36
  end
26
37
 
27
- attr_accessor :username, :password, :pretty_print_api
38
+ attr_accessor :username, :password, :pretty_print_api, :open_timeout, :read_timeout, :write_timeout
28
39
  attr_reader :environment, :logger, :logger_level, :logger_file
29
40
 
30
41
  def initialize
31
42
  @environment = default_environment
32
43
  @username = ENV.fetch('IMIS_USERNAME', nil)
33
44
  @password = ENV.fetch('IMIS_PASSWORD', nil)
45
+ @open_timeout = Integer(ENV.fetch('IMIS_OPEN_TIMEOUT', DEFAULT_OPEN_TIMEOUT).to_s, 10)
46
+ @read_timeout = Integer(ENV.fetch('IMIS_READ_TIMEOUT', DEFAULT_READ_TIMEOUT).to_s, 10)
47
+ @write_timeout = Integer(ENV.fetch('IMIS_WRITE_TIMEOUT', DEFAULT_WRITE_TIMEOUT).to_s, 10)
34
48
  @base_logger = Logger.new($stdout, level: :info)
35
49
  @logger = ActiveSupport::TaggedLogging.new(@base_logger)
36
50
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Usps
4
4
  module Imis
5
- VERSION = '0.14.1'
5
+ VERSION = '0.15.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: usps-imis-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julian Fiander