default storage engine
This commit is contained in:
parent
006a50b8e3
commit
04a8c0123c
@ -17,3 +17,5 @@ RETRY_ATTEMPTS = 3
|
|||||||
RETRY_WAIT_MINUTES = 60
|
RETRY_WAIT_MINUTES = 60
|
||||||
|
|
||||||
DOCUMENT_CLASSES = {}
|
DOCUMENT_CLASSES = {}
|
||||||
|
|
||||||
|
DEFAULT_STORAGE_ENGINE = 'dummy'
|
||||||
|
@ -16,7 +16,7 @@ class Kernel(object):
|
|||||||
mongo_db='oyster', mongo_log_maxsize=100000000,
|
mongo_db='oyster', mongo_log_maxsize=100000000,
|
||||||
user_agent='oyster', rpm=60, timeout=300,
|
user_agent='oyster', rpm=60, timeout=300,
|
||||||
retry_attempts=3, retry_wait_minutes=60,
|
retry_attempts=3, retry_wait_minutes=60,
|
||||||
doc_classes=None,
|
doc_classes=None, default_storage_engine='dummy',
|
||||||
):
|
):
|
||||||
"""
|
"""
|
||||||
configurable for ease of testing, only one should be instantiated
|
configurable for ease of testing, only one should be instantiated
|
||||||
@ -53,14 +53,16 @@ class Kernel(object):
|
|||||||
self.storage[name] = StorageCls(self)
|
self.storage[name] = StorageCls(self)
|
||||||
|
|
||||||
# set document classes
|
# set document classes
|
||||||
_doc_class_fields = ('update_mins', 'storage_engine',
|
_doc_class_fields = ('update_mins', 'onchanged')
|
||||||
'onchanged')
|
|
||||||
self.doc_classes = doc_classes or {}
|
self.doc_classes = doc_classes or {}
|
||||||
for dc_name, dc_props in self.doc_classes.iteritems():
|
for dc_name, dc_props in self.doc_classes.iteritems():
|
||||||
for key in _doc_class_fields:
|
for key in _doc_class_fields:
|
||||||
if key not in dc_props:
|
if key not in dc_props:
|
||||||
raise ValueError('doc_class %s missing key %s' %
|
raise ValueError('doc_class %s missing key %s' %
|
||||||
(dc_name, key))
|
(dc_name, key))
|
||||||
|
# set a default storage engine
|
||||||
|
if 'storage_engine' not in dc_props:
|
||||||
|
dc_props['storage_engine'] = default_storage_engine
|
||||||
|
|
||||||
def _wipe(self):
|
def _wipe(self):
|
||||||
""" exists primarily for debug use, wipes entire db """
|
""" exists primarily for debug use, wipes entire db """
|
||||||
@ -269,6 +271,7 @@ def _get_configured_kernel():
|
|||||||
retry_attempts=settings.RETRY_ATTEMPTS,
|
retry_attempts=settings.RETRY_ATTEMPTS,
|
||||||
retry_wait_minutes=settings.RETRY_WAIT_MINUTES,
|
retry_wait_minutes=settings.RETRY_WAIT_MINUTES,
|
||||||
doc_classes=settings.DOCUMENT_CLASSES,
|
doc_classes=settings.DOCUMENT_CLASSES,
|
||||||
|
default_storage_engine=settings.DEFAULT_STORAGE_ENGINE,
|
||||||
)
|
)
|
||||||
|
|
||||||
kernel = _get_configured_kernel()
|
kernel = _get_configured_kernel()
|
||||||
|
@ -18,9 +18,8 @@ class KernelTests(TestCase):
|
|||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
doc_classes = {'default':
|
doc_classes = {'default':
|
||||||
{'update_mins': 30, 'storage_engine': 'dummy',
|
# omit doc class, defaults to dummy
|
||||||
'onchanged': []
|
{'update_mins': 30, 'onchanged': [] },
|
||||||
},
|
|
||||||
'fast-update':
|
'fast-update':
|
||||||
{'update_mins': 1 / 60., 'storage_engine': 'dummy',
|
{'update_mins': 1 / 60., 'storage_engine': 'dummy',
|
||||||
'onchanged': []
|
'onchanged': []
|
||||||
|
Loading…
Reference in New Issue
Block a user