Simple HTTP client which takes request data from redis
Project description
redis2http
Redis2http takes request data from redis and performs HTTP request. Mostly used to implement web-hook calls
Why not requests.get/requests.post ?
Most likely you want main program to run fast and spend very short time on calling hook. HTTP requests are not good for it - it may fail or be slow for many reasons. On other hand, LPUSH operation with local redis is always very quick and very reliable.
redis2http is good if a) You do not need to wait for HTTP request completion b) You do not need to get any reply from request
Install
pip3 install redis2http
If you want to start on boot (as root or sudo):
cp /usr/local/redis2http/redis2http.service /etc/systemd/system/
systemctl daemon-reload
systemctl enable redis2http
systemctl start redis2http
Usage for CLI
CLI is not main purpose for redis2http, but it's good for testing. Examples:
To start as service in foreground (for debugging), just run redis2http.py
(not options required).
To send request via redis (for debugging):
redis2http.py --send GET https://google.com/
After this (in less then second), you can see result in redis2http service output. If redis2http runs as systemd service, then sudo journalctl -u redis2http
.
Usage from Python or from whatever (via redis)
Put JSON-encoded data structure to http_requests_queue
list (or use -q
for other key name). Python example:
data = {
'method': 'GET',
'url': 'https://example.com/hook',
'payload': None
}
request = json.dumps(data)
redis_connection.sadd('http_requests_queue', request)
Set vs List
redis2http may use queue as redis object of type set
or type list
. You may specify type as --type
CLI option. Default is set
.
If you will use set and submit same data twice, only one HTTP request will be performed. If you will use list, both requests will be performed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file redis2http-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: redis2http-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e89db2d06178db5d6b17bf5b765bf7cf0aef1cf38288a73aeca9d731a6e5ce9 |
|
MD5 | 0f8ea26d62805883c7e961366c122b18 |
|
BLAKE2b-256 | af535708b90c84965503a85735af2bcd0e7fbd2440847a0480b1825390284f5c |