Skip to content

Commit 2e0e107

Browse files
feat: bump default connection pool size limit to minimum of 99
1 parent 70eb621 commit 2e0e107

File tree

4 files changed

+14
-6
lines changed

4 files changed

+14
-6
lines changed

lib/finch_api/client.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ def initialize(
103103
client_secret: ENV["FINCH_CLIENT_SECRET"],
104104
access_token: nil,
105105
base_url: ENV["FINCH_BASE_URL"],
106-
max_retries: FinchAPI::Client::DEFAULT_MAX_RETRIES,
107-
timeout: FinchAPI::Client::DEFAULT_TIMEOUT_IN_SECONDS,
108-
initial_retry_delay: FinchAPI::Client::DEFAULT_INITIAL_RETRY_DELAY,
109-
max_retry_delay: FinchAPI::Client::DEFAULT_MAX_RETRY_DELAY
106+
max_retries: self.class::DEFAULT_MAX_RETRIES,
107+
timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
108+
initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
109+
max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
110110
)
111111
base_url ||= "https://api.tryfinch.com"
112112

lib/finch_api/internal/transport/pooled_net_requester.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ class PooledNetRequester
1111
# https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49
1212
KEEP_ALIVE_TIMEOUT = 30
1313

14+
DEFAULT_MAX_CONNECTIONS = [Etc.nprocessors, 99].max
15+
1416
class << self
1517
# @api private
1618
#
@@ -184,7 +186,7 @@ def execute(request)
184186
# @api private
185187
#
186188
# @param size [Integer]
187-
def initialize(size: Etc.nprocessors)
189+
def initialize(size: self.class::DEFAULT_MAX_CONNECTIONS)
188190
@mutex = Mutex.new
189191
@size = size
190192
@pools = {}

rbi/finch_api/internal/transport/pooled_net_requester.rbi

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ module FinchAPI
2222
# https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49
2323
KEEP_ALIVE_TIMEOUT = 30
2424

25+
DEFAULT_MAX_CONNECTIONS = T.let(T.unsafe(nil), Integer)
26+
2527
class << self
2628
# @api private
2729
sig { params(url: URI::Generic).returns(Net::HTTP) }
@@ -67,7 +69,9 @@ module FinchAPI
6769

6870
# @api private
6971
sig { params(size: Integer).returns(T.attached_class) }
70-
def self.new(size: Etc.nprocessors)
72+
def self.new(
73+
size: FinchAPI::Internal::Transport::PooledNetRequester::DEFAULT_MAX_CONNECTIONS
74+
)
7175
end
7276
end
7377
end

sig/finch_api/internal/transport/pooled_net_requester.rbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ module FinchAPI
1515

1616
KEEP_ALIVE_TIMEOUT: 30
1717

18+
DEFAULT_MAX_CONNECTIONS: Integer
19+
1820
def self.connect: (URI::Generic url) -> top
1921

2022
def self.calibrate_socket_timeout: (top conn, Float deadline) -> void

0 commit comments

Comments
 (0)