Class: HC::HTTPClient::ManagerFacade
- Inherits:
-
Object
- Object
- HC::HTTPClient::ManagerFacade
- Defined in:
- lib/hc-httpclient.rb
Overview
Facade over http client and connection manager, setup, start, shutdown
Example Settings
See: hc.apache.org/httpclient-3.x/preference-api.html
manager_params.max_total_connections = 200
manager_params.connection_timeout = 1500 #ms
manager_params.default_max_connections_per_host = 20
manager_params.stale_checking_enabled = false
client_params.connection_manager_timeout = 3000 #ms
client_params.so_timeout = 3000 #ms
client_params.set_parameter( HttpMethodParams::RETRY_HANDLER,
DefaultHttpMethodRetryHandler.new( 2, false ) )
client_params. = CookiePolicy::IGNORE_COOKIES
Note, use of set_parameter style settings will increase the likelihood of 4.x compatibility
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
The HttpClient instance available after start.
-
#client_params ⇒ Object
readonly
Client parameters.
-
#manager_params ⇒ Object
readonly
Manager parameters.
Instance Method Summary collapse
-
#initialize ⇒ ManagerFacade
constructor
A new instance of ManagerFacade.
-
#shutdown ⇒ Object
Shutdown and close the connection manager and client.
-
#start ⇒ Object
Given previously set parameters, construct connection manager and client.
Constructor Details
#initialize ⇒ ManagerFacade
Returns a new instance of ManagerFacade.
76 77 78 79 80 81 82 83 |
# File 'lib/hc-httpclient.rb', line 76 def initialize @manager_params = HttpConnectionManagerParams.new @client_params = HttpClientParams.new @client = nil @connection_manager = nil end |
Instance Attribute Details
#client ⇒ Object (readonly)
The HttpClient instance available after start
68 69 70 |
# File 'lib/hc-httpclient.rb', line 68 def client @client end |
#client_params ⇒ Object (readonly)
Client parameters
74 75 76 |
# File 'lib/hc-httpclient.rb', line 74 def client_params @client_params end |
#manager_params ⇒ Object (readonly)
Manager parameters
71 72 73 |
# File 'lib/hc-httpclient.rb', line 71 def manager_params @manager_params end |
Instance Method Details
#shutdown ⇒ Object
Shutdown and close the connection manager and client.
95 96 97 98 99 |
# File 'lib/hc-httpclient.rb', line 95 def shutdown @connection_manager.shutdown if @connection_manager @client = nil @connection_manager = nil end |
#start ⇒ Object
Given previously set parameters, construct connection manager and client.
87 88 89 90 91 92 |
# File 'lib/hc-httpclient.rb', line 87 def start @connection_manager = MultiThreadedHttpConnectionManager.new() @connection_manager.params = @manager_params @client = HttpClient.new( @client_params, @connection_manager ); end |