Skip to content

Add keep_alive and max_connections configuration to IncogniaAPI#101

Open
alangalvino wants to merge 3 commits intomainfrom
keep-alive
Open

Add keep_alive and max_connections configuration to IncogniaAPI#101
alangalvino wants to merge 3 commits intomainfrom
keep-alive

Conversation

@alangalvino
Copy link
Copy Markdown

PR body:

Summary

  • Add keep_alive (bool) and max_connections (int) parameters to IncogniaAPI
  • When keep_alive=True, a requests.Session is created with an HTTPAdapter configured with pool_connections and pool_maxsize set to max_connections
  • The session is shared between the API client and TokenManager so all requests (including token refresh) benefit from connection reuse
  • Defaults to keep_alive=False (existing behavior) and max_connections=10

@alangalvino alangalvino requested a review from a team as a code owner April 16, 2026 21:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds optional HTTP connection reuse to the Python client by introducing keep_alive and max_connections configuration and wiring a shared requests.Session through both the API client and token refresh path.

Changes:

  • Add keep_alive/max_connections parameters to IncogniaAPI and BaseRequest, enabling a pooled requests.Session when configured.
  • Allow TokenManager to accept an injected BaseRequest so token refresh uses the same connection pool.
  • Add tests and README documentation describing the new configuration.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
incognia/base_request.py Creates and uses a pooled requests.Session via HTTPAdapter when keep_alive=True.
incognia/api.py Exposes keep_alive/max_connections on IncogniaAPI and shares the request instance with TokenManager.
incognia/token_manager.py Supports dependency injection of BaseRequest so auth requests reuse the same session.
tests/test_base_request.py Adds unit tests for the keep-alive/session behavior.
README.md Documents the new keep-alive configuration and shows an example.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread README.md Outdated
Comment thread tests/test_base_request.py
Comment thread incognia/base_request.py
Comment thread incognia/api.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants