Skip to content
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
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.4.1"
".": "0.5.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
configured_endpoints: 18
openapi_spec_hash: 153617b7252b1b12f21043b2a1246f8b
openapi_spec_hash: 539798fac79a1eeebf9ac4faa0492455
config_hash: 6dcf08c4324405f152d1da9fc11ab04a
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Changelog

## 0.5.0 (2025-10-28)

Full Changelog: [v0.4.1...v0.5.0](https://github.com/openlayer-ai/openlayer-ruby/compare/v0.4.1...v0.5.0)

### Features

* **api:** api update ([e686c41](https://github.com/openlayer-ai/openlayer-ruby/commit/e686c41ce85b71f1d36e6e98c57fd1e15b0dba50))
* **api:** api update ([062f345](https://github.com/openlayer-ai/openlayer-ruby/commit/062f34578e996d2f947d6175656e29657bd6d325))
* handle thread interrupts in the core HTTP client ([ec67b44](https://github.com/openlayer-ai/openlayer-ruby/commit/ec67b44714f9f117f129ace368b40e47e9ec3f3c))


### Bug Fixes

* absolutely qualified uris should always override the default ([e245d11](https://github.com/openlayer-ai/openlayer-ruby/commit/e245d1191c6f5e73a5f4431a8bfff1989d828648))

## 0.4.1 (2025-10-15)

Full Changelog: [v0.4.0...v0.4.1](https://github.com/openlayer-ai/openlayer-ruby/compare/v0.4.0...v0.4.1)
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:
openlayer (0.4.1)
openlayer (0.5.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 @@ -17,7 +17,7 @@ To use this gem, install via Bundler by adding the following to your application
<!-- x-release-please-start-version -->

```ruby
gem "openlayer", "~> 0.4.1"
gem "openlayer", "~> 0.5.0"
```

<!-- x-release-please-end -->
Expand Down
54 changes: 30 additions & 24 deletions lib/openlayer/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 Openlayer::Errors::APITimeoutError.new(url: url, request: req)
Expand All @@ -174,8 +182,6 @@ def execute(request)
body = Openlayer::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
5 changes: 3 additions & 2 deletions lib/openlayer/internal/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,9 @@ def join_parsed_uri(lhs, rhs)
base_path, base_query = lhs.fetch_values(:path, :query)
slashed = base_path.end_with?("/") ? base_path : "#{base_path}/"

parsed_path, parsed_query = parse_uri(rhs.fetch(:path)).fetch_values(:path, :query)
override = URI::Generic.build(**rhs.slice(:scheme, :host, :port), path: parsed_path)
merged = {**parse_uri(rhs.fetch(:path)), **rhs.except(:path, :query)}
parsed_path, parsed_query = merged.fetch_values(:path, :query)
override = URI::Generic.build(**merged.slice(:scheme, :host, :port), path: parsed_path)

joined = URI.join(URI::Generic.build(lhs.except(:path, :query)), slashed, override)
query = deep_merge(
Expand Down
Loading