Class: Broadcast::Connection
- Inherits:
-
Object
- Object
- Broadcast::Connection
- Defined in:
- lib/broadcast/connection.rb
Overview
HTTP transport. Owns request building, response/error mapping, retries, redirects, and debug logging. Split out of Client so Client stays a thin facade over configuration and resource sub-clients.
Constant Summary collapse
- MAX_REDIRECTS =
3- REDIRECT_CODES =
[301, 302, 307, 308].freeze
Instance Method Summary collapse
-
#initialize(config) ⇒ Connection
constructor
A new instance of Connection.
- #request(method, path, payload = nil, headers: {}, raw: false) ⇒ Object
Constructor Details
#initialize(config) ⇒ Connection
Returns a new instance of Connection.
24 25 26 27 |
# File 'lib/broadcast/connection.rb', line 24 def initialize(config) @config = config @debug_logger = DebugLogger.new(config) end |
Instance Method Details
#request(method, path, payload = nil, headers: {}, raw: false) ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/broadcast/connection.rb', line 31 def request(method, path, payload = nil, headers: {}, raw: false) uri = build_uri(path, method, payload) context = { headers: headers, raw: raw, redirects: 0 } retry_with_backoff { execute(method, uri, payload, context) } rescue Net::OpenTimeout, Net::ReadTimeout => e raise Broadcast::TimeoutError, "Request timeout: #{e.}" end |