Skip to content

Commit ef7cf3f

Browse files
Configurable Persistent HTTP Pool
1 parent d668658 commit ef7cf3f

File tree

4 files changed

+24
-4
lines changed

4 files changed

+24
-4
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ You can use the following commands to run:
4444
* All the tests: ``rake test``. **This will run integration tests if you have .env file or env vars setup**
4545
* Run storage suite of tests: ``rake test:unit``, ``rake test:integration``
4646
* One particular test file: ``ruby -I".\blob\lib;.\common\lib;.\table\lib;.\queue\lib;.\file\lib;test" "<path of the test file>"``
47+
* Use ``MT_COMPAT=1 rake test`` environment variable in case you get ``NameError: uninitialized constant MiniTest`` (see https://github.com/minitest/minitest/commit/a2c6c18570f6f0a1bf6af70fe3b6d9599a13fdd6)
4748

4849
### Testing Features
4950
As you develop a feature, you'll need to write tests to ensure quality. Your changes should be covered by both unit tests and integration tests. You should also run existing tests related to your change to address any unexpected breaks.
@@ -71,4 +72,4 @@ We strive to release each new feature for each of our environments at the same t
7172
### Review Process
7273
We expect all guidelines to be met before accepting a pull request. As such, we will work with you to address issues we find by leaving comments in your code. Please understand that it may take a few iterations before the code is accepted as we maintain high standards on code quality. Once we feel comfortable with a contribution, we will validate the change and accept the pull request.
7374

74-
Thank you for any contributions! Please let the team know if you have any questions or concerns about our contribution policy.
75+
Thank you for any contributions! Please let the team know if you have any questions or concerns about our contribution policy.

common/lib/azure/storage/common/core/http_client.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def build_http(uri)
7272
end || nil
7373
Faraday.new(uri, ssl: ssl_options, proxy: proxy_options) do |conn|
7474
conn.use FaradayMiddleware::FollowRedirects
75-
conn.adapter :net_http_persistent, pool_size: 5 do |http|
75+
conn.adapter :net_http_persistent, pool_size: ENV.fetch('AZURE_STORAGE_HTTP_POOL', 5).to_i do |http|
7676
# yields Net::HTTP::Persistent
7777
http.idle_timeout = 100
7878
end

common/lib/azure/storage/common/service/storage_service.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,8 @@ class << self
239239

240240
# Registers the callback when sending the request
241241
# The headers in the request can be viewed or changed in the code block
242-
def register_request_callback
243-
@request_callback = Proc.new
242+
def register_request_callback(&block)
243+
@request_callback = proc &block
244244
end
245245

246246
# Get the request location.

test/unit/core/http_client_test.rb

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,24 @@
6363
_(Azure::Storage::Common::Client::create.agents(uri).proxy.uri).must_equal https_proxy_uri
6464
end
6565
end
66+
67+
describe "when net_http_persistent pool is set" do
68+
let(:pool_size) { 10 }
69+
70+
before do
71+
ENV["AZURE_STORAGE_HTTP_POOL"] = pool_size.to_s
72+
end
73+
74+
after do
75+
ENV["AZURE_STORAGE_HTTP_POOL"] = nil
76+
end
77+
78+
it "should set the pool size for connection" do
79+
agent = Azure::Storage::Common::Client::create.agents(uri)
80+
size = agent.builder.adapter.instance_variable_get(:@args)[0][:pool_size]
81+
82+
_(size).must_equal pool_size
83+
end
84+
end
6685
end
6786
end

0 commit comments

Comments
 (0)