Skip to main content

A simple view to help know what the callback is doing on django-stomp usage

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_stomp_debug_callback-2.0.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_stomp_debug_callback-2.0.0-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file django_stomp_debug_callback-2.0.0.tar.gz.

File metadata

  • Download URL: django_stomp_debug_callback-2.0.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.10.17 Linux/6.11.0-1013-azure

File hashes

Hashes for django_stomp_debug_callback-2.0.0.tar.gz
Algorithm Hash digest
SHA256 f8fbca850d0fb8b5dfb961267917b775c531df4b34c7dca43d1f5a43c6b3e97d
MD5 e1dd4d9610fcbc6b9c3bd0466eb59d95
BLAKE2b-256 05ca02b992ed935ae7423309b5827c017ac46ba52f3a2ef13ba7ffc27cc395eb

See more details on using hashes here.

File details

Details for the file django_stomp_debug_callback-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for django_stomp_debug_callback-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d7987ae680f0c1b8022482889645cb512ddcc25b74c3c98cc923e72b92001e13
MD5 b81fe7fc2c440699e414b820198ea2d4
BLAKE2b-256 38e91baef8489b3b7058b3678490116ff3f6a1b001c4a7cad3c6810b67e46abc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page