Skip to main content

Base redis pubsub django wrapper

Project description

Django pubsub

Django Pubsub wrapper.

Installation with requirements.txt

djangopubsub

With PIP

$ pip install djangopubsub

Add app to django settings

INSTALLED_APPS = (
    ...,
    'djangopubsub'
)

Available settings and defaults:

BASE_DIR = ''  # Root directory for handlers lookup
EVENT_HANDLERS_DIR_NAME = 'event_handlers'  #  Directory with handlers on every app module
HANDLER_FILES_PREFIX = 'handlers_' # handlers file prefix
REDIS_HOST = 'localhost'
REDIS_PORT = 6379 
PUB_SUB_EMIT = True  # Avoid to emit message when emit is called (for tests)

Decorator

@on_event('EVENT_NAME')
def func_to_execute(data):
    pass

Pubsub emit

from djangopubsub.djangoPubSub import DjangoPubSub
DjangoPubSub().emit('EVENT_NAME', {})

Pubsub receiver

Needs redis running on port:REDIS_PORT

python manage.py runpubsubreceiver --settings=your_proyect.settings

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

djangopubsub-0.3.5.tar.gz (3.7 kB view hashes)

Uploaded Source

Supported by

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