@@ -14,7 +14,7 @@ class << self
1414 # @param name: Name of the server whose settings will be returned.
1515 # If `nil` then an array of settings of all servers under the passed `backend`
1616 # will be returned.
17- #: (String?, String?, Configuration?) -> Faraday::Response
17+ #: (String?, String?, Configuration?) -> Faraday::Response?
1818 def get_runtime_settings ( backend :, name : nil , config : nil )
1919 config ||= CONFIG
2020 if backend . nil? || backend . empty?
@@ -30,7 +30,7 @@ def get_runtime_settings(backend:, name: nil, config: nil)
3030
3131 # @param backend: Name of the backend
3232 # @param name: Name of the server whose transient settings should be updated.
33- #: (String?, String?, Hash[top, top], Configuration?) -> Faraday::Response
33+ #: (String?, String?, Hash[top, top], Configuration?) -> Faraday::Response?
3434 def update_transient_settings ( backend :, name :, settings :, config : nil )
3535 config ||= CONFIG
3636 if backend . nil? || backend . empty?
@@ -48,37 +48,44 @@ def update_transient_settings(backend:, name:, settings:, config: nil)
4848
4949 private
5050
51- #: (Symbol, String | Pathname, Configuration) { (Faraday::Request) -> void } -> Faraday::Response
51+ #: (Symbol, String | Pathname, Configuration) { (Faraday::Request) -> void } -> Faraday::Response?
5252 def send_request ( method :, path :, config :, &block )
5353 request = T . let ( nil , T . nilable ( Faraday ::Request ) )
54- response = config . connection . public_send ( method , path ) do |req |
54+ conn = config . connection
55+ response = conn . public_send ( method , path ) do |req |
5556 block . call ( req )
5657 req . options . timeout = config . timeout
5758 request = req
59+ break if config . mock?
5860 end
5961
60- log_communication ( T . must ( request ) , response , logger : config . logger )
62+ log_communication (
63+ conn . build_url ( path ) ,
64+ T . must ( request ) ,
65+ response ,
66+ logger : config . logger ,
67+ )
6168
6269 response
6370 end
6471
65- #: (Faraday::Request, Faraday::Response, Logger?) -> void
66- def log_communication ( request , response , logger :)
72+ #: (String, Faraday::Request, Faraday::Response? , Logger?) -> void
73+ def log_communication ( url , request , response , logger :)
6774 request_hash = {
6875 method : request . http_method ,
69- url : response . env . url ,
76+ url : url ,
7077 params : request . params ,
7178 headers : request . headers ,
7279 body : request . body ,
7380 }
7481 response_hash = {
75- status : response . status ,
76- body : response . body ,
77- headers : response . headers ,
82+ status : response & .status ,
83+ body : response & .body ,
84+ headers : response & .headers ,
7885 }
7986
8087 logger &.debug <<~REQ
81- HAProxy #{ request . http_method . to_s . upcase } #{ response . env . url }
88+ HAProxy #{ request . http_method . to_s . upcase } #{ url }
8289 -----REQUEST-----
8390 #{ ::JSON . pretty_generate request_hash }
8491 -----RESPONSE-----
0 commit comments