# Path: django_datawatch/backends/base.py
# class BaseBackend(object):
#     def enqueue(self, slug, run_async=True):
#         raise NotImplementedError('enqueue not implemented')
# 
#     def refresh(self, slug, run_async=True):
#         raise NotImplementedError('refresh not implemented')
# 
#     def run(self, slug, identifier, run_async=True, user_forced_refresh=False):
#         raise NotImplementedError('run not implemented')
# 
# Path: django_datawatch/tasks.py
# @shared_task
# def django_datawatch_enqueue(slug, *args, **kwargs):
#     logger.debug('enqueuing checks for %s', slug)
#     synchronous.Backend().enqueue(slug=slug)
# 
# @shared_task
# def django_datawatch_run(slug, identifier, user_forced_refresh=False, *args, **kwargs):
#     logger.debug('running check %s for identifier %s (forced refresh %s)', slug, identifier, user_forced_refresh)
#     synchronous.Backend().run(slug=slug, identifier=identifier, user_forced_refresh=user_forced_refresh)
# 
# @shared_task
# def django_datawatch_refresh(slug, *args, **kwargs):
#     logger.debug('refreshing check results for %s', slug)
#     synchronous.Backend().refresh(slug=slug)


from django_datawatch.backends.base import BaseBackend
from django_datawatch.tasks import django_datawatch_enqueue, \
    django_datawatch_run, django_datawatch_refresh
# -*- coding: UTF-8 -*-
from __future__ import unicode_literals



class Backend(BaseBackend):
    """
    A wrapper backend to execute tasks asynchronously in celery
    """
    def enqueue(self, slug, run_async=True):
        kwargs = dict(kwargs=dict(slug=slug))
        if run_async:
            django_datawatch_enqueue.apply_async(**kwargs)
        else:
            django_datawatch_enqueue.apply(**kwargs)

    def refresh(self, slug, run_async=True):
        kwargs = dict(kwargs=dict(slug=slug))
        if run_async:
            django_datawatch_refresh.apply_async(**kwargs)
        else:

# Path: django_datawatch/backends/base.py
# class BaseBackend(object):
#     def enqueue(self, slug, run_async=True):
#         raise NotImplementedError('enqueue not implemented')
# 
#     def refresh(self, slug, run_async=True):
#         raise NotImplementedError('refresh not implemented')
# 
#     def run(self, slug, identifier, run_async=True, user_forced_refresh=False):
#         raise NotImplementedError('run not implemented')
# 
# Path: django_datawatch/tasks.py
# @shared_task
# def django_datawatch_enqueue(slug, *args, **kwargs):
#     logger.debug('enqueuing checks for %s', slug)
#     synchronous.Backend().enqueue(slug=slug)
# 
# @shared_task
# def django_datawatch_run(slug, identifier, user_forced_refresh=False, *args, **kwargs):
#     logger.debug('running check %s for identifier %s (forced refresh %s)', slug, identifier, user_forced_refresh)
#     synchronous.Backend().run(slug=slug, identifier=identifier, user_forced_refresh=user_forced_refresh)
# 
# @shared_task
# def django_datawatch_refresh(slug, *args, **kwargs):
#     logger.debug('refreshing check results for %s', slug)
#     synchronous.Backend().refresh(slug=slug)


# Path: django_datawatch/backends/celery.py
from django_datawatch.backends.base import BaseBackend
from django_datawatch.tasks import django_datawatch_enqueue, \
    django_datawatch_run, django_datawatch_refresh

# -*- coding: UTF-8 -*-
from __future__ import unicode_literals



class Backend(BaseBackend):
    """
    A wrapper backend to execute tasks asynchronously in celery
    """
    def enqueue(self, slug, run_async=True):
        kwargs = dict(kwargs=dict(slug=slug))
        if run_async:
            django_datawatch_enqueue.apply_async(**kwargs)
        else:
            django_datawatch_enqueue.apply(**kwargs)

    def refresh(self, slug, run_async=True):
        kwargs = dict(kwargs=dict(slug=slug))
        if run_async:
            django_datawatch_refresh.apply_async(**kwargs)
        else:

            django_datawatch_refresh.apply(**kwargs)