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 .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: ["3.0", "3.1", "3.2", "3.3"]
ruby: ["3.1", "3.1", "3.2", "3.4"]

name: ${{ matrix.ruby }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/spec/reports/
/tmp/
.rspec_status
/benchmark_results/
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ inherit_gem:

AllCops:
DisplayCopNames: true
TargetRubyVersion: 3.0
TargetRubyVersion: 3.1
Include:
- bin/console
- Gemfile
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
source "https://rubygems.org"
gemspec

gem "benchmark-ips"
gem "bundler"
gem "coveralls"
gem "memory_profiler"
gem "pry"
gem "rake"
gem "rspec"
Expand Down
6 changes: 5 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
ezclient (1.7.2)
ezclient (1.7.3)
http (>= 4)

GEM
Expand All @@ -21,6 +21,7 @@ GEM
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0)
benchmark-ips (2.14.0)
bigdecimal (3.1.8)
coderay (1.1.3)
concurrent-ruby (1.3.4)
Expand Down Expand Up @@ -59,6 +60,7 @@ GEM
llhttp-ffi (0.5.0)
ffi-compiler (~> 1.0)
rake (~> 13.0)
memory_profiler (1.1.0)
method_source (1.1.0)
mime-types (3.5.2)
mime-types-data (~> 3.2015)
Expand Down Expand Up @@ -155,9 +157,11 @@ PLATFORMS
ruby

DEPENDENCIES
benchmark-ips
bundler
coveralls
ezclient!
memory_profiler
pry
rake
rspec
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Valid client options are:

- `api_auth` – arguments for `ApiAuth.sign!` (see https://github.com/mgomes/api_auth)
- `basic_auth` – arguments for basic authentication (either a hash with `:user` and `:pass` keys or a two-element array)
- `cleanup_interval` – interval for cleaning up timed out connections in seconds (default: 60)
- `cookies` – a hash of cookies (or `HTTP::CookieJar` object) for requests
- `headers` – a hash of headers for requests
- `keep_alive` – timeout for persistent connection in seconds
Expand Down Expand Up @@ -80,10 +81,25 @@ module MyApp
end
```

Alose note that, as of now, EzClient will
Also note that, as of now, EzClient will
automatically retry the request on any `HTTP::ConnectionError` exception in this case which may possibly result in two requests
received by a server (see https://github.com/httprb/http/issues/459).

### Closing persistent connections

If you need to close all persistent connections (e.g., when forking), you can use the `truncate!` method:

```ruby
client = EzClient.new(keep_alive: 100)

# ... make some requests ...

# Close all persistent connections and clear caches
client.truncate!
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему это называется truncate? Мб лучше как-то типа reset?

```

This is particularly useful in forking scenarios (e.g., when using Pitchfork or Puma in fork mode).

## Callbacks and retrying

You can provide `on_complete`, `on_error` and `on_retry` callbacks like this:
Expand Down
Loading