1818module Async
1919 module HTTP
2020 DEFAULT_RETRIES = 3
21- DEFAULT_CONNECTION_LIMIT = nil
2221
2322 class Client < ::Protocol ::HTTP ::Methods
2423 # Provides a robust interface to a server.
@@ -30,12 +29,12 @@ class Client < ::Protocol::HTTP::Methods
3029 # @param protocol [Protocol::HTTP1 | Protocol::HTTP2 | Protocol::HTTPS] the protocol to use.
3130 # @param scheme [String] The default scheme to set to requests.
3231 # @param authority [String] The default authority to set to requests.
33- def initialize ( endpoint , protocol : endpoint . protocol , scheme : endpoint . scheme , authority : endpoint . authority , retries : DEFAULT_RETRIES , connection_limit : DEFAULT_CONNECTION_LIMIT )
32+ def initialize ( endpoint , protocol : endpoint . protocol , scheme : endpoint . scheme , authority : endpoint . authority , retries : DEFAULT_RETRIES , ** options )
3433 @endpoint = endpoint
3534 @protocol = protocol
3635
3736 @retries = retries
38- @pool = make_pool ( connection_limit )
37+ @pool = make_pool ( ** options )
3938
4039 @scheme = scheme
4140 @authority = authority
@@ -191,8 +190,20 @@ def make_response(request, connection)
191190 return response
192191 end
193192
194- def make_pool ( connection_limit )
195- Async ::Pool ::Controller . wrap ( limit : connection_limit ) do
193+ def assign_default_tags ( tags )
194+ tags [ :endpoint ] = @endpoint . to_s
195+ tags [ :protocol ] = @protocol . to_s
196+ end
197+
198+ def make_pool ( **options )
199+ if connection_limit = options . delete ( :connection_limit )
200+ warn "The connection_limit: option is deprecated, please use limit: instead." , uplevel : 2
201+ options [ :limit ] = connection_limit
202+ end
203+
204+ self . assign_default_tags ( options [ :tags ] ||= { } )
205+
206+ Async ::Pool ::Controller . wrap ( **options ) do
196207 Console . logger . debug ( self ) { "Making connection to #{ @endpoint . inspect } " }
197208
198209 @protocol . client ( @endpoint . connect )
0 commit comments