Engine _cls postfix is not correct
Some of the time these attributes are types but other times they are functions, to avoid the confusion of naming these with a '_cls' postfix move to having a '_factory' postfix since these attributes generate other objects (which is what factories do). Change-Id: I73edd0c794223d719fbfbd0608c985cb335c8c26
This commit is contained in:
@@ -48,11 +48,11 @@ class ActionEngine(base.EngineBase):
|
||||
reversion to commence. See the valid states in the states module to learn
|
||||
more about what other states the tasks & flow being ran can go through.
|
||||
"""
|
||||
_graph_action_cls = graph_action.FutureGraphAction
|
||||
_graph_analyzer_cls = graph_analyzer.GraphAnalyzer
|
||||
_task_action_cls = task_action.TaskAction
|
||||
_task_executor_cls = executor.SerialTaskExecutor
|
||||
_retry_action_cls = retry_action.RetryAction
|
||||
_graph_action_factory = graph_action.FutureGraphAction
|
||||
_graph_analyzer_factory = graph_analyzer.GraphAnalyzer
|
||||
_task_action_factory = task_action.TaskAction
|
||||
_task_executor_factory = executor.SerialTaskExecutor
|
||||
_retry_action_factory = retry_action.RetryAction
|
||||
|
||||
def __init__(self, flow, flow_detail, backend, conf):
|
||||
super(ActionEngine, self).__init__(flow, flow_detail, backend, conf)
|
||||
@@ -173,35 +173,35 @@ class ActionEngine(base.EngineBase):
|
||||
execution_graph = flow_utils.flatten(self._flow)
|
||||
if execution_graph.number_of_nodes() == 0:
|
||||
raise exc.Empty("Flow %s is empty." % self._flow.name)
|
||||
self._analyzer = self._graph_analyzer_cls(execution_graph,
|
||||
self.storage)
|
||||
self._analyzer = self._graph_analyzer_factory(execution_graph,
|
||||
self.storage)
|
||||
if self._task_executor is None:
|
||||
self._task_executor = self._task_executor_cls()
|
||||
self._task_executor = self._task_executor_factory()
|
||||
if self._task_action is None:
|
||||
self._task_action = self._task_action_cls(self.storage,
|
||||
self._task_executor,
|
||||
self.task_notifier)
|
||||
self._task_action = self._task_action_factory(self.storage,
|
||||
self._task_executor,
|
||||
self.task_notifier)
|
||||
if self._retry_action is None:
|
||||
self._retry_action = self._retry_action_cls(self.storage,
|
||||
self.task_notifier)
|
||||
self._root = self._graph_action_cls(self._analyzer,
|
||||
self.storage,
|
||||
self._task_action,
|
||||
self._retry_action)
|
||||
self._retry_action = self._retry_action_factory(self.storage,
|
||||
self.task_notifier)
|
||||
self._root = self._graph_action_factory(self._analyzer,
|
||||
self.storage,
|
||||
self._task_action,
|
||||
self._retry_action)
|
||||
self._compiled = True
|
||||
return
|
||||
|
||||
|
||||
class SingleThreadedActionEngine(ActionEngine):
|
||||
"""Engine that runs tasks in serial manner."""
|
||||
_storage_cls = t_storage.SingleThreadedStorage
|
||||
_storage_factory = t_storage.SingleThreadedStorage
|
||||
|
||||
|
||||
class MultiThreadedActionEngine(ActionEngine):
|
||||
"""Engine that runs tasks in parallel manner."""
|
||||
_storage_cls = t_storage.MultiThreadedStorage
|
||||
_storage_factory = t_storage.MultiThreadedStorage
|
||||
|
||||
def _task_executor_cls(self):
|
||||
def _task_executor_factory(self):
|
||||
return executor.ParallelTaskExecutor(self._executor)
|
||||
|
||||
def __init__(self, flow, flow_detail, backend, conf, **kwargs):
|
||||
|
||||
@@ -42,12 +42,13 @@ class EngineBase(object):
|
||||
def storage(self):
|
||||
"""The storage unit for this flow."""
|
||||
if self._storage is None:
|
||||
self._storage = self._storage_cls(self._flow_detail, self._backend)
|
||||
self._storage = self._storage_factory(self._flow_detail,
|
||||
self._backend)
|
||||
return self._storage
|
||||
|
||||
@abc.abstractproperty
|
||||
def _storage_cls(self):
|
||||
"""Storage class that will be used to generate storage objects."""
|
||||
def _storage_factory(self):
|
||||
"""Storage factory that will be used to generate storage objects."""
|
||||
|
||||
@abc.abstractmethod
|
||||
def compile(self):
|
||||
|
||||
@@ -34,9 +34,9 @@ class WorkerBasedActionEngine(engine.ActionEngine):
|
||||
:keyword transport_options: transport specific options
|
||||
"""
|
||||
|
||||
_storage_cls = t_storage.SingleThreadedStorage
|
||||
_storage_factory = t_storage.SingleThreadedStorage
|
||||
|
||||
def _task_executor_cls(self):
|
||||
def _task_executor_factory(self):
|
||||
if self._executor is not None:
|
||||
return self._executor
|
||||
return executor.WorkerTaskExecutor(
|
||||
|
||||
Reference in New Issue
Block a user