Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "1.112.0"
".": "1.113.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 220
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-77bf980f154392e3f2070aa38e38d8927ba8cff23d81bb6e5733fdd52a4e67b5.yml
openapi_spec_hash: 18a92821c3e77f158295ca50b4aa33b0
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-569770c31254c7f2a732392f0a960ab529ea93d792991d0ad4b77ddb03cef90b.yml
openapi_spec_hash: ad8426915b3eb92c26351e2d87a6d891
config_hash: f0b80170c2ea09811aeae3f1e94bc422
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 1.113.0 (2025-10-23)

Full Changelog: [v1.112.0...v1.113.0](https://github.com/Increase/increase-ruby/compare/v1.112.0...v1.113.0)

### Features

* **api:** api update ([f6e1c26](https://github.com/Increase/increase-ruby/commit/f6e1c262384c439eeeb7d9914b51d51e6aa5b89b))
* handle thread interrupts in the core HTTP client ([cbddb16](https://github.com/Increase/increase-ruby/commit/cbddb162a4273e627d3df4acde3a9eeac3652715))

## 1.112.0 (2025-10-22)

Full Changelog: [v1.111.0...v1.112.0](https://github.com/Increase/increase-ruby/compare/v1.111.0...v1.112.0)
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
increase (1.112.0)
increase (1.113.0)
connection_pool

GEM
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ To use this gem, install via Bundler by adding the following to your application
<!-- x-release-please-start-version -->

```ruby
gem "increase", "~> 1.112.0"
gem "increase", "~> 1.113.0"
```

<!-- x-release-please-end -->
Expand Down
54 changes: 30 additions & 24 deletions lib/increase/internal/transport/pooled_net_requester.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,40 +128,48 @@ def execute(request)
url, deadline = request.fetch_values(:url, :deadline)

req = nil
eof = false
finished = false
closing = nil

# rubocop:disable Metrics/BlockLength
enum = Enumerator.new do |y|
next if finished

with_pool(url, deadline: deadline) do |conn|
req, closing = self.class.build_request(request) do
self.class.calibrate_socket_timeout(conn, deadline)
end

self.class.calibrate_socket_timeout(conn, deadline)
unless conn.started?
conn.keep_alive_timeout = self.class::KEEP_ALIVE_TIMEOUT
conn.start
end
eof = false
closing = nil
::Thread.handle_interrupt(Object => :never) do
::Thread.handle_interrupt(Object => :immediate) do
req, closing = self.class.build_request(request) do
self.class.calibrate_socket_timeout(conn, deadline)
end

self.class.calibrate_socket_timeout(conn, deadline)
conn.request(req) do |rsp|
y << [req, rsp]
break if finished

rsp.read_body do |bytes|
y << bytes.force_encoding(Encoding::BINARY)
break if finished
self.class.calibrate_socket_timeout(conn, deadline)
unless conn.started?
conn.keep_alive_timeout = self.class::KEEP_ALIVE_TIMEOUT
conn.start
end

self.class.calibrate_socket_timeout(conn, deadline)
conn.request(req) do |rsp|
y << [req, rsp]
break if finished

rsp.read_body do |bytes|
y << bytes.force_encoding(Encoding::BINARY)
break if finished

self.class.calibrate_socket_timeout(conn, deadline)
end
eof = true
end
end
ensure
begin
conn.finish if !eof && conn&.started?
ensure
closing&.call
end
eof = true
end
ensure
conn.finish if !eof && conn&.started?
end
rescue Timeout::Error
raise Increase::Errors::APITimeoutError.new(url: url, request: req)
Expand All @@ -174,8 +182,6 @@ def execute(request)
body = Increase::Internal::Util.fused_enum(enum, external: true) do
finished = true
loop { enum.next }
ensure
closing&.call
end
[Integer(response.code), response, body]
end
Expand Down
2 changes: 1 addition & 1 deletion lib/increase/models/check_transfer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ module BalanceCheck
# The available balance of the account must be at least the amount of the check, and a Pending Transaction will be created for the full amount.
FULL = :full

# No balance check will performed; a zero-dollar Pending Transaction will be created.
# No balance check will performed when the check transfer is initiated. A zero-dollar Pending Transaction will be created. The balance will still be checked when the Inbound Check Deposit is created.
NONE = :none

# @!method self.values
Expand Down
2 changes: 1 addition & 1 deletion lib/increase/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Increase
VERSION = "1.112.0"
VERSION = "1.113.0"
end
2 changes: 1 addition & 1 deletion rbi/increase/models/check_transfer.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ module Increase
# The available balance of the account must be at least the amount of the check, and a Pending Transaction will be created for the full amount.
FULL = T.let(:full, Increase::CheckTransfer::BalanceCheck::TaggedSymbol)

# No balance check will performed; a zero-dollar Pending Transaction will be created.
# No balance check will performed when the check transfer is initiated. A zero-dollar Pending Transaction will be created. The balance will still be checked when the Inbound Check Deposit is created.
NONE = T.let(:none, Increase::CheckTransfer::BalanceCheck::TaggedSymbol)

sig do
Expand Down
2 changes: 1 addition & 1 deletion sig/increase/models/check_transfer.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ module Increase
# The available balance of the account must be at least the amount of the check, and a Pending Transaction will be created for the full amount.
FULL: :full

# No balance check will performed; a zero-dollar Pending Transaction will be created.
# No balance check will performed when the check transfer is initiated. A zero-dollar Pending Transaction will be created. The balance will still be checked when the Inbound Check Deposit is created.
NONE: :none

def self?.values: -> ::Array[Increase::Models::CheckTransfer::balance_check]
Expand Down
23 changes: 23 additions & 0 deletions test/increase/internal/util_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,29 @@ def test_rewind_closing
assert_equal(0, steps)
end

def test_thread_interrupts
once = 0
que = Queue.new
enum = Enumerator.new do |y|
10.times { y << _1 }
ensure
once = once.succ
end

fused_1 = Increase::Internal::Util.fused_enum(enum, external: true) { loop { enum.next } }
fused_2 = Increase::Internal::Util.chain_fused(fused_1) { fused_1.each(&_1) }
fused_3 = Increase::Internal::Util.chain_fused(fused_2) { fused_2.each(&_1) }

th = ::Thread.new do
que << "🐶"
fused_3.each { sleep(10) }
end

assert_equal("🐶", que.pop)
th.kill.join
assert_equal(1, once)
end

def test_closing
arr = [1, 2, 3]
once = 0
Expand Down