18
18
module Async
19
19
module HTTP
20
20
DEFAULT_RETRIES = 3
21
- DEFAULT_CONNECTION_LIMIT = nil
22
21
23
22
class Client < ::Protocol ::HTTP ::Methods
24
23
# Provides a robust interface to a server.
@@ -30,12 +29,12 @@ class Client < ::Protocol::HTTP::Methods
30
29
# @param protocol [Protocol::HTTP1 | Protocol::HTTP2 | Protocol::HTTPS] the protocol to use.
31
30
# @param scheme [String] The default scheme to set to requests.
32
31
# @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 )
34
33
@endpoint = endpoint
35
34
@protocol = protocol
36
35
37
36
@retries = retries
38
- @pool = make_pool ( connection_limit )
37
+ @pool = make_pool ( ** options )
39
38
40
39
@scheme = scheme
41
40
@authority = authority
@@ -191,8 +190,20 @@ def make_response(request, connection)
191
190
return response
192
191
end
193
192
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
196
207
Console . logger . debug ( self ) { "Making connection to #{ @endpoint . inspect } " }
197
208
198
209
@protocol . client ( @endpoint . connect )
0 commit comments