Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add punt hook to drop admin-chosen messages #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions roost_backend/subscribers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from django.core.exceptions import AppRegistryNotReady
from django.db import IntegrityError, transaction
from django.db.models import Q
from django.conf import settings
from djangorestframework_camel_case.util import underscoreize
import setproctitle
import zephyr
Expand Down Expand Up @@ -235,6 +236,10 @@ async def zephyr_handler(self):
if notice.opcode.lower() == b'ping':
# Ignoring pings
continue
if settings.ROOST_CHECK_PUNT(notice):
_LOGGER.getChild('punt').info("[%s] zephyr handler punting znotice %s, %s",
self.log_prefix, notice, notice.__dict__)
continue
# This appears to be an incoming message.
msg = django.apps.apps.get_model('roost_backend', 'Message').from_notice(notice)
_LOGGER.debug('%s', msg)
Expand Down
10 changes: 10 additions & 0 deletions roost_ng/settings/roost.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,13 @@
# Making this operator tweakable so we can experiment.
# JS roost had a 100 message limit. Snipe asked for 128 messages.
ROOST_MESSAGES_MAX_LIMIT = cfg.get('message_max_limit', 128)

def ROOST_CHECK_PUNT(znotice):
"""Hook to optionally drop certain messages before adding to DB

Useful if there's a class with some useful messages, but also a high
rate of messages that nobody needs to see that unnecessarily load the
server.

Returns a bool indicating whether or not to punt a message."""
return False