A simple view to help know what the callback is doing on django-stomp usage
Project description
Django stomp debug callback
This functionality helps you comprehend and enhance your callback code used with the Django STOMP library.
As this project uses a view to call your callback function, it's possible to extract quite essential data that you can use to optimize your implementation.
See an example of this approach in action thanks to Django Debug Toolbar:
Installation
pip install django-stomp-debug-callback
Django stomp debug callback configuration
Basically the configuration is simple, just insert the django_stomp_debug_callback
on INSTALLED_APPS
and
in your application's urls
code include the debug callback view route.
from django.conf import settings
if settings.DEBUG:
urlpatterns += [
path("debug-callback/", include("django_stomp_debug_callback.urls")), # django stomp callback urls
]
- Check if
django-stomp
stay intoINSTALLED_APPS
How to use ?
This route is a simple POST
type route that expects to receive some parameters to trigger the callback function.
body parameter:
callback_function_path
: The path to callback function to be calledpayload_body
: payload body to be sent to de callback functionpayload_headers
: headers to be sent to de callback function
curl example
curl --request POST \
--url http://0.0.0.0:8000/debug-callback/debug-function/ \
--data '{
"callback_function_path": "path.to.the.callback.function",
"payload_body": {
"fake": "body"
},
"payload_headers": {
"fake": "headers"
}
}'
How to use with django-debug-toolbar ?
Configuration for the django-debug-toolbar here.
- The first step is install de django-debug-toolbar in your app
pip install django-debug-toolbar
- The second step is to configure the urls (Recommended only insert this rule id
DEBUG
isTrue
)
from django.conf import settings
if settings.DEBUG:
urlpatterns += [
path("debug-callback/", include("django_stomp_debug_callback.urls")), # django stomp callback urls
path("debug-toolbar/", include("debug_toolbar.urls")) # django debug toolbar
]
- The third step is to check the settings, these settings will include the middleware and debug apps to main settings
in your .env
##################
#### DEBUG LIB CONFIGURATION
DEBUG_APPS = debug_toolbar,django_stomp_debug_callback
DEBUG_MIDDLEWARE = debug_toolbar.middleware.DebugToolbarMiddleware
in your setting
import os
DEBUG = True # only to developer mode never in production app
# DEBUG CONFIGURATION
if DEBUG:
DEBUG_TOOLBAR_CONFIG = {"SHOW_TOOLBAR_CALLBACK": (lambda request: True)}
INTERNAL_IPS = ["0.0.0.0"]
DEBUG_APPS = os.getenv("DEBUG_APPS")
if DEBUG_APPS:
INSTALLED_APPS += DEBUG_APPS.split(",")
DEBUG_MIDDLEWARE = os.getenv("DEBUG_MIDDLEWARE")
if DEBUG_MIDDLEWARE:
MIDDLEWARE += DEBUG_MIDDLEWARE.split(",")
Now you can see the debug panel in your admin url (localhost:8000/admin) and you can choose the route you want to see the requests to the bank in a given view with timing details and explain options and see the most problematic query of your stream.
Tests
You can run the tests with docker
docker-compose up tests
Or using tox
pipenv run tox
Lint + code formatter
The use of .pre-commit-config.yaml
flake8, black, isort and pylint.
You can run the .pre-commit-config.yaml
with docker
docker-compose up lint-formatter
Or using pre-commit
pre-commit run --all-files
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 Distribution
Built Distribution
File details
Details for the file django-stomp-debug-callback-1.0.0.tar.gz
.
File metadata
- Download URL: django-stomp-debug-callback-1.0.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.11.0-1028-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cf8e85ed6881cf15048eaea18e51c6761cd013e15f190620281df77652a8ada |
|
MD5 | 666ac7eb4fb5636f321da0a86adfbd91 |
|
BLAKE2b-256 | 0e31ba87e335b113d6d4d0c355c2267f22712760291eb02cabaf4c0742347646 |
File details
Details for the file django_stomp_debug_callback-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: django_stomp_debug_callback-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.10 Linux/5.11.0-1028-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9386e833937cb535a02ebd814c328a3027391e97a22594743ea5dcedfa3ed4c1 |
|
MD5 | 31f73e74cb1d690c5b0c21b14e385a66 |
|
BLAKE2b-256 | 79601563dd511e82576f968a6ba258280b849da084516f23c4ebefaca8b7a7be |