Exemplo n.º 1
0
def init_plugin(plugin):
    from sentry.plugins.base import bindings

    plugin.setup(bindings)

    # Register contexts from plugins if necessary
    if hasattr(plugin, "get_custom_contexts"):
        from sentry.interfaces.contexts import contexttype

        for cls in plugin.get_custom_contexts() or ():
            contexttype(cls)

    if hasattr(plugin, "get_cron_schedule") and plugin.is_enabled():
        schedules = plugin.get_cron_schedule()
        if schedules:
            settings.CELERYBEAT_SCHEDULE.update(schedules)

    if hasattr(plugin, "get_worker_imports") and plugin.is_enabled():
        imports = plugin.get_worker_imports()
        if imports:
            settings.CELERY_IMPORTS += tuple(imports)

    if hasattr(plugin, "get_worker_queues") and plugin.is_enabled():
        from kombu import Queue

        for queue in plugin.get_worker_queues():
            try:
                name, routing_key = queue
            except ValueError:
                name = routing_key = queue
            q = Queue(name, routing_key=routing_key)
            q.durable = False
            settings.CELERY_QUEUES.append(q)
Exemplo n.º 2
0
    def init_plugin_instance(plugin):
        # TODO: Call this when the plugin is run on load time (review requirements first)
        from sentry.plugins import bindings
        plugin.setup(bindings)

        # Register contexts from plugins if necessary
        if hasattr(plugin, 'get_custom_contexts'):
            from sentry.interfaces.contexts import contexttype
            for cls in plugin.get_custom_contexts() or ():
                contexttype(cls)

        if (hasattr(plugin, 'get_cron_schedule') and plugin.is_enabled()):
            schedules = plugin.get_cron_schedule()
            if schedules:
                settings.CELERYBEAT_SCHEDULE.update(schedules)

        if (hasattr(plugin, 'get_worker_imports') and plugin.is_enabled()):
            imports = plugin.get_worker_imports()
            if imports:
                settings.CELERY_IMPORTS += tuple(imports)

        if (hasattr(plugin, 'get_worker_queues') and plugin.is_enabled()):
            from kombu import Queue
            for queue in plugin.get_worker_queues():
                try:
                    name, routing_key = queue
                except ValueError:
                    name = routing_key = queue
                q = Queue(name, routing_key=routing_key)
                q.durable = False
                settings.CELERY_QUEUES.append(q)
Exemplo n.º 3
0
def init_plugin(plugin):
    from sentry.plugins import bindings
    plugin.setup(bindings)

    # Register contexts from plugins if necessary
    if hasattr(plugin, 'get_custom_contexts'):
        from sentry.interfaces.contexts import contexttype
        for cls in plugin.get_custom_contexts() or ():
            contexttype(cls)

    if (hasattr(plugin, 'get_cron_schedule') and plugin.is_enabled()):
        schedules = plugin.get_cron_schedule()
        if schedules:
            settings.CELERYBEAT_SCHEDULE.update(schedules)

    if (hasattr(plugin, 'get_worker_imports') and plugin.is_enabled()):
        imports = plugin.get_worker_imports()
        if imports:
            settings.CELERY_IMPORTS += tuple(imports)

    if (hasattr(plugin, 'get_worker_queues') and plugin.is_enabled()):
        from kombu import Queue
        for queue in plugin.get_worker_queues():
            try:
                name, routing_key = queue
            except ValueError:
                name = routing_key = queue
            q = Queue(name, routing_key=routing_key)
            q.durable = False
            settings.CELERY_QUEUES.append(q)
Exemplo n.º 4
0
from kombu import Exchange, Queue

exchange = Exchange("tasks_enzh")
exchange.durable = False
queue = Queue("tasks_enzh", exchange, routing_key="tasks_enzh")
queue.durable = False
queue.no_ack = True

CELERY_QUEUES = (queue, )

CELERY_ROUTES = {
    'tasks_enzh.translation': {
        "queue": "tasks_enzh",
        "routing_key": "tasks_enzh"
    },
}