Class: Pinot::HttpClient
- Inherits:
-
Object
- Object
- Pinot::HttpClient
- Defined in:
- lib/pinot/transport.rb
Constant Summary collapse
- MAX_POOL_SIZE =
5- KEEP_ALIVE_TIMEOUT =
30
Instance Method Summary collapse
- #get(url, headers: {}) ⇒ Object
-
#initialize(timeout: nil, tls_config: nil) ⇒ HttpClient
constructor
A new instance of HttpClient.
- #post(url, body:, headers: {}) ⇒ Object
Constructor Details
#initialize(timeout: nil, tls_config: nil) ⇒ HttpClient
Returns a new instance of HttpClient.
12 13 14 15 16 17 |
# File 'lib/pinot/transport.rb', line 12 def initialize(timeout: nil, tls_config: nil) @timeout = timeout @tls_config = tls_config @pool = {} @pool_mutex = Mutex.new end |
Instance Method Details
#get(url, headers: {}) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/pinot/transport.rb', line 29 def get(url, headers: {}) uri = URI.parse(url) with_connection(url) do |http| req = Net::HTTP::Get.new(uri.request_uri) headers.each { |k, v| req[k] = v } http.request(req) end end |
#post(url, body:, headers: {}) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/pinot/transport.rb', line 19 def post(url, body:, headers: {}) uri = URI.parse(url) with_connection(url) do |http| req = Net::HTTP::Post.new(uri.request_uri) headers.each { |k, v| req[k] = v } req.body = body http.request(req) end end |