Git Product home page Git Product logo

djeventstream's Introduction

djeventstream

Framework for receiving events sent by the Python loggers.

This is the Django-based mate to loghandlersplus. It can take events from a Python logging framework HTPPHandler, or a loghandlersplus SNSHandler, and convert those to Django signals.

To use:

git clone https://github.com/edx/djeventstream.git
sudo python setup.py install

Add the handler to INSTALLED_APPS in settings.py:

INSTALLED_APPS = (
    ...
    'djeventstream.httphandler',
    ...
)

Add a view to urls.py:

url(r'^httpevent$', 'djeventstream.httphandler.views.http_view'),

To receive the events, add a Django receiver:

from djeventstream.signals import event_received
from django.dispatch import receiver

@receiver(event_received)
def f(sender, **kwargs):
    print kwargs['msg']

One minor caveat: Be aware that Django loads many parts of an application lazily (e.g. a view is loaded when it is first called). If you don't want to lose events, make sure the receiver is placed somewhere where it is imported on application startup.

For SNS events, settings.py needs to contain one of two things:

SNS_PUBLIC = True

In this case, your application will handle SNS events from anyone. This is primarily useful for debugging. For deployment, you should explicitly list the ARNs you would like to accept subscriptions from:

SNS_PUBLIC = False
SNS_SUBSCRIPTIONS = ["arn:aws:sns:us-east-2:1234567890:sns_arn"]

Please note that this framework does not, yet, verify signatures on events. You cannot trust that that the events came from Amazon without a secondary security mechanism (the same is true of the HTTP handler).

djeventstream's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.