-
Notifications
You must be signed in to change notification settings - Fork 1
feat!: reuse TCP connection by default #49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ class Configuration | |
|
|
||
| attr_accessor :client_id, :client_secret, :host, :keep_alive, :max_connections | ||
|
|
||
| def configure(client_id:, client_secret:, host: nil, keep_alive: false, max_connections: nil) | ||
| def configure(client_id:, client_secret:, host: nil, keep_alive: true, max_connections: nil) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it a breaking change, or is it okay to assume it as the default? I'm asking so we can decide about the version. |
||
| validate_connection_settings!(keep_alive: keep_alive, max_connections: max_connections) | ||
|
|
||
| @client_id = client_id | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,8 @@ module Incognia | |
| Incognia.configure( | ||
| client_id: 'client_id', | ||
| client_secret: 'client_secret', | ||
| host: 'https://api.incognia.com/api' | ||
| host: 'https://api.incognia.com/api', | ||
| keep_alive: false | ||
| ) | ||
| end | ||
|
|
||
|
|
@@ -258,6 +259,37 @@ module Incognia | |
| before { Singleton.__init__(described_class) } | ||
| after { instance.reset! } | ||
|
|
||
| it "uses the persistent adapter by default" do | ||
| Incognia.configure( | ||
| client_id: 'client_id', | ||
| client_secret: 'client_secret', | ||
| host: 'https://api.incognia.com/api' | ||
| ) | ||
|
|
||
| allow_any_instance_of(Faraday::RackBuilder).to receive(:adapter).and_call_original | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did we need to mock it before the |
||
| expect_any_instance_of(Faraday::RackBuilder).to receive(:adapter) | ||
| .with(:net_http_persistent) | ||
| .and_call_original | ||
|
|
||
| instance.connection | ||
| end | ||
|
|
||
|
figueredo marked this conversation as resolved.
|
||
| it "uses the default adapter when keep_alive is false" do | ||
| Incognia.configure( | ||
| client_id: 'client_id', | ||
| client_secret: 'client_secret', | ||
| host: 'https://api.incognia.com/api', | ||
| keep_alive: false | ||
| ) | ||
|
|
||
| allow_any_instance_of(Faraday::RackBuilder).to receive(:adapter).and_call_original | ||
| expect_any_instance_of(Faraday::RackBuilder).to receive(:adapter) | ||
| .with(Faraday.default_adapter) | ||
| .and_call_original | ||
|
|
||
| instance.connection | ||
| end | ||
|
|
||
| it "uses the persistent adapter with the configured max_connections" do | ||
| Incognia.configure( | ||
| client_id: 'client_id', | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was it sent as null?
As you're already treating nil, we can change the default to be nil, wdyt?