Debian Codegraph @

celery_haystack/conf.py

raw symbols SCIP
1 from django.conf import settings # noqa
2 from django.core.exceptions import ImproperlyConfigured
3 from haystack import constants
4 from haystack.management.commands import update_index as cmd
5 from appconf import AppConf
6
7
8 class CeleryHaystack(AppConf):
9 #: The default alias to
10 DEFAULT_ALIAS = None
11 #: The delay (in seconds) before task will be executed (Celery countdown)
12 COUNTDOWN = 0
13 #: The delay (in seconds) after which a failed index is retried
14 RETRY_DELAY = 5 * 60
15 #: The number of retries that are done
16 MAX_RETRIES = 1
17 #: The default Celery task class
18 DEFAULT_TASK = 'celery_haystack.tasks.CeleryHaystackSignalHandler'
19 #: The name of the celery queue to use, or None for default
20 QUEUE = None
21 #: Whether the task should be handled transaction safe
22 TRANSACTION_SAFE = True
23 #: Whether the task results should be ignored
24 IGNORE_RESULT = False
25
26 #: The batch size used by the CeleryHaystackUpdateIndex task
27 COMMAND_BATCH_SIZE = None
28 #: The max age of items used by the CeleryHaystackUpdateIndex task
29 COMMAND_AGE = None
30 #: Whether to remove items from the index that aren't in the DB anymore
31 COMMAND_REMOVE = False
32 #: The number of multiprocessing workers used by the CeleryHaystackUpdateIndex task
33 COMMAND_WORKERS = 0
34 #: The names of apps to run update_index for
35 COMMAND_APPS = []
36 #: The verbosity level of the update_index call
37 COMMAND_VERBOSITY = 1
38
39 def configure_default_alias(self, value):
40 return value or getattr(constants, 'DEFAULT_ALIAS', None)
41
42 def configure_command_batch_size(self, value):
43 return value or getattr(cmd, 'DEFAULT_BATCH_SIZE', None)
44
45 def configure_command_age(self, value):
46 return value or getattr(cmd, 'DEFAULT_AGE', None)
47
48 def configure(self):
49 data = {}
50 for name, value in self.configured_data.items():
51 if name in ('RETRY_DELAY', 'MAX_RETRIES',
52 'COMMAND_WORKERS', 'COMMAND_VERBOSITY'):
53 value = int(value)
54 data[name] = value
55 return data
56
57
58 signal_processor = getattr(settings, 'HAYSTACK_SIGNAL_PROCESSOR', "celery_haystack.signals.CelerySignalProcessor")