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 +4 -4
- data/lib/usps/imis/api.rb +5 -4
- data/lib/usps/imis/config.rb +16 -2
- data/lib/usps/imis/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3b20172987ecd5b1bd13b0f142b616d71704e906aed312d71dca5e9b63c8432c
|
|
4
|
+
data.tar.gz: aab0fa56ded131c2a116203ea292c15ab024d408309a03144aeb5e795df77820
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
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 =
|
|
272
|
-
http.read_timeout =
|
|
273
|
-
http.write_timeout =
|
|
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
|
data/lib/usps/imis/config.rb
CHANGED
|
@@ -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[
|
|
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
|
|
data/lib/usps/imis/version.rb
CHANGED