Skip to main content

MBQ PubSub

Project description

mbq.pubsub

PyPI Version PyPI License Python Versions Travis CI Status

Installation

$ pip install mbq.pubsub
🚀✨

Guaranteed fresh.

Configuration

# settings.py

SERVICE_NAME = "my-service"

PUBSUB = {
    "ENV": mbq.get_environment("ENV_NAME"),
    "SERVICE": SERVICE_NAME,
    "QUEUES": [
        "foo-updates",
        "bar-updates",
    ],
    "MESSAGE_HANDLERS": {
        "foo.updated": "path.to.handlers.handle_foo_updated",
        "bar.updated": "path.to.handlers.handle_bar_updated",
    },
}

INSTALLED_APPS = {
  ...
  'mbq.pubsub',
  ...
}
# convox.yml

services:
  foo-consumer:
    image: {{DOCKER_IMAGE_NAME}}
    command: newrelic-admin run-python -m manage pubsub consume --queue foo-updates
    init: true
    environment:
      - "*"

  bar-consumer:
    image: {{DOCKER_IMAGE_NAME}}
    command: newrelic-admin run-python -m manage pubsub consume --queue bar-updates
    init: true
    environment:
      - "*"

Using PubSub Without a Database

If your service does not have a database - fear not. The Infra team hath taken pity on you and your brethren. Simply add the setting "USE_DATABASE": False to your PUBSUB config.

Things to keep in mind:

  • There will be no Django admin for viewing/deleting/replaying DLQ messages.
  • To replay the DLQ use the management command ./manage.py pubsub replay --queue <queue_name> <number_of_messages>.

Local Development

Add 127.0.0.1 pubsub.lcl.mbq.io to your /etc/hosts.

Find the env/pubsub/lcl.env Secure Note in 1Password and copy it to env/lcl.env.

$ pbpaste > env/lcl.env

Run migrations and bring up admin the server:

$ docker-compose run tests-admin python -m manage migrate
$ docker-compose up tests-admin

To use the Django admin, you'll need a superuser:

$ docker-compose run tests-admin python -m manage createsuperuser

To end-to-end test mbq.pubsub, you can publish a test message from SNS with:

$ docker-compose run tests-admin python -m manage publish_exception

Then bring up the consumer:

$ docker-compose up pubsub-pubsub-consume-updates

The test message will eventually land on the DLQ, which you can inspect & replay from http://pubsub.lcl.mbq.io:8080/admin/pubsub/undeliverablemessage

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

mbq.pubsub-1.1.0.tar.gz (13.3 kB view details)

Uploaded Source

File details

Details for the file mbq.pubsub-1.1.0.tar.gz.

File metadata

  • Download URL: mbq.pubsub-1.1.0.tar.gz
  • Upload date:
  • Size: 13.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.7

File hashes

Hashes for mbq.pubsub-1.1.0.tar.gz
Algorithm Hash digest
SHA256 6cd2d2297adee4a6c277dcbea6af0217878e1b9e823c2a43c785b37a0c235f35
MD5 545a813a9d9baf863f3193e4f6c67948
BLAKE2b-256 b04a42cba0a26594691111c832151101a4b6d60c0d90e920a45a3dafb6120af2

See more details on using hashes here.

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