Skip to main content

Django stomp debug callback

Build Status Maintainability Test Coverage Quality Gate Status Code style: black PyPI version GitHub

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:

Django callback view utilization

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 into INSTALLED_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 called
  • payload_body: payload body to be sent to de callback function
  • payload_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.

pip install django-debug-toolbar
  • The second step is to configure the urls (Recommended only insert this rule id DEBUG is True)
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

Metadata

Release files for django-stomp-debug-callback 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-stomp-debug-callback 2.0.0
File Size Uploaded
django_stomp_debug_callback-2.0.0.tar.gz 4.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-stomp-debug-callback 2.0.0
File Interpreter ABI Platform
django_stomp_debug_callback-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.5 kB

Release files / django_stomp_debug_callback-2.0.0.tar.gz

Download URL django_stomp_debug_callback-2.0.0.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f8fbca850d0fb8b5dfb961267917b775c531df4b34c7dca43d1f5a43c6b3e97d
BLAKE2b-256 checksum
How to use checksums
05ca02b992ed935ae7423309b5827c017ac46ba52f3a2ef13ba7ffc27cc395eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.17 Linux/6.11.0-1013-azure

Release files / django_stomp_debug_callback-2.0.0-py3-none-any.whl

Download URL django_stomp_debug_callback-2.0.0-py3-none-any.whl
Size 6.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7987ae680f0c1b8022482889645cb512ddcc25b74c3c98cc923e72b92001e13
BLAKE2b-256 checksum
How to use checksums
38e91baef8489b3b7058b3678490116ff3f6a1b001c4a7cad3c6810b67e46abc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.10.17 Linux/6.11.0-1013-azure

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page