Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable Persistent HTTP Pool #231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ You can use the following commands to run:
* All the tests: ``rake test``. **This will run integration tests if you have .env file or env vars setup**
* Run storage suite of tests: ``rake test:unit``, ``rake test:integration``
* One particular test file: ``ruby -I".\blob\lib;.\common\lib;.\table\lib;.\queue\lib;.\file\lib;test" "<path of the test file>"``
* Use ``MT_COMPAT=1 rake test`` environment variable in case you get ``NameError: uninitialized constant MiniTest`` (see https://github.com/minitest/minitest/commit/a2c6c18570f6f0a1bf6af70fe3b6d9599a13fdd6)

### Testing Features
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.
Expand Down Expand Up @@ -71,4 +72,4 @@ We strive to release each new feature for each of our environments at the same t
### Review Process
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.

Thank you for any contributions! Please let the team know if you have any questions or concerns about our contribution policy.
Thank you for any contributions! Please let the team know if you have any questions or concerns about our contribution policy.
2 changes: 1 addition & 1 deletion common/lib/azure/storage/common/core/http_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def build_http(uri)
end || nil
Faraday.new(uri, ssl: ssl_options, proxy: proxy_options) do |conn|
conn.use FaradayMiddleware::FollowRedirects
conn.adapter :net_http_persistent, pool_size: 5 do |http|
conn.adapter :net_http_persistent, pool_size: ENV.fetch('AZURE_STORAGE_HTTP_POOL', 5).to_i do |http|
# yields Net::HTTP::Persistent
http.idle_timeout = 100
end
Expand Down
4 changes: 2 additions & 2 deletions common/lib/azure/storage/common/service/storage_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ class << self

# Registers the callback when sending the request
# The headers in the request can be viewed or changed in the code block
def register_request_callback
@request_callback = Proc.new
def register_request_callback(&block)
@request_callback = proc &block
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixes Ruby's >= 3.0: ArgumentError (tried to create Proc object without a block)

end

# Get the request location.
Expand Down
19 changes: 19 additions & 0 deletions test/unit/core/http_client_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,24 @@
_(Azure::Storage::Common::Client::create.agents(uri).proxy.uri).must_equal https_proxy_uri
end
end

describe "when net_http_persistent pool is set" do
let(:pool_size) { 10 }

before do
ENV["AZURE_STORAGE_HTTP_POOL"] = pool_size.to_s
end

after do
ENV["AZURE_STORAGE_HTTP_POOL"] = nil
end

it "should set the pool size for connection" do
agent = Azure::Storage::Common::Client::create.agents(uri)
size = agent.builder.adapter.instance_variable_get(:@args)[0][:pool_size]

_(size).must_equal pool_size
end
end
end
end