Invoker Guard
A simple, transport-agnostic wrapper for executing callables with robust, configurable retry logic, powered by tenacity.
It allows you to write your retry and validation logic once and apply it to different HTTP libraries like requests, httpx, and niquests.
Installation
Install the core library:
pip install invoker-guard
Then, install the support for the HTTP library you want to use:
# For requests support
pip install invoker-guard[requests]
# For httpx support
pip install invoker-guard[httpx]
# For everything
pip install invoker-guard[requests,httpx,niquests]
How to Use
The library's main function is invoke. You provide it with:
- A
callable_action(alambdathat calls your HTTP library). - A
RetryConfigobject defining your rules. - A
Transportobject that matches your library.
Example with requests
import requests
from invoker_guard import invoke, RetryConfig, RetryError, REQUESTS_TRANSPORT
# Define rules
config = RetryConfig(expected_status_codes=[200])
# Define action
url = "https://api.example.com/data"
action = lambda: requests.get(url, timeout=10)
# Invoke it
try:
response = invoke(action, config, transport=REQUESTS_TRANSPORT)
print("Success:", response.json())
except RetryError as e:
print("Failed after all retries:", e)
Example with httpx
The logic is identical—just swap the library and the transport object.
import httpx
from invoker_guard import invoke, RetryConfig, RetryError, HTTPX_TRANSPORT
# Define rules (can be the same config object)
config = RetryConfig(expected_status_codes=[200], required_json_keys=["id"])
# Define action for httpx
url = "https://api.example.com/data"
action = lambda: httpx.get(url, timeout=10)
# Invoke it
try:
response = invoke(action, config, transport=HTTPX_TRANSPORT)
print("Success:", response.json())
except RetryError as e:
print("Failed after all retries:", e)
Metadata
Release files for invoker-guard 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| invoker_guard-0.3.0.tar.gz | 7.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| invoker_guard-0.3.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 15.5 kB
Release files / invoker_guard-0.3.0.tar.gz
| Download URL | invoker_guard-0.3.0.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b0c8c179bcbb4ff73245f90631d5d94243ce3572655cbfde391eb546312c7988
|
|
BLAKE2b-256 checksum How to use checksums |
1cc6aee4af8b4f2af9bf51fa0dd9fbeb39ad564d3729fd0fa43f99d0b25a6a8d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.8
|
Release files / invoker_guard-0.3.0-py3-none-any.whl
| Download URL | invoker_guard-0.3.0-py3-none-any.whl |
|---|---|
| Size | 7.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0d010e43f3fcc3a574ed7fa195cfd597f4eb773746d1e236647fc822d1a94bce
|
|
BLAKE2b-256 checksum How to use checksums |
6617b1790e53afc94b8ee0cdc34777b9b98ae47912926b058ea91166954fd898
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.8
|
Security for invoker-guard 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.