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:
Joshua Harlow
2014-05-04 21:29:45 -07:00
parent 8ebce5b027
commit 50696ac555
3 changed files with 26 additions and 25 deletions

View File

@@ -48,11 +48,11 @@ class ActionEngine(base.EngineBase):
reversion to commence. See the valid states in the states module to learn 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. more about what other states the tasks & flow being ran can go through.
""" """
_graph_action_cls = graph_action.FutureGraphAction _graph_action_factory = graph_action.FutureGraphAction
_graph_analyzer_cls = graph_analyzer.GraphAnalyzer _graph_analyzer_factory = graph_analyzer.GraphAnalyzer
_task_action_cls = task_action.TaskAction _task_action_factory = task_action.TaskAction
_task_executor_cls = executor.SerialTaskExecutor _task_executor_factory = executor.SerialTaskExecutor
_retry_action_cls = retry_action.RetryAction _retry_action_factory = retry_action.RetryAction
def __init__(self, flow, flow_detail, backend, conf): def __init__(self, flow, flow_detail, backend, conf):
super(ActionEngine, self).__init__(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) execution_graph = flow_utils.flatten(self._flow)
if execution_graph.number_of_nodes() == 0: if execution_graph.number_of_nodes() == 0:
raise exc.Empty("Flow %s is empty." % self._flow.name) raise exc.Empty("Flow %s is empty." % self._flow.name)
self._analyzer = self._graph_analyzer_cls(execution_graph, self._analyzer = self._graph_analyzer_factory(execution_graph,
self.storage) self.storage)
if self._task_executor is None: 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: if self._task_action is None:
self._task_action = self._task_action_cls(self.storage, self._task_action = self._task_action_factory(self.storage,
self._task_executor, self._task_executor,
self.task_notifier) self.task_notifier)
if self._retry_action is None: if self._retry_action is None:
self._retry_action = self._retry_action_cls(self.storage, self._retry_action = self._retry_action_factory(self.storage,
self.task_notifier) self.task_notifier)
self._root = self._graph_action_cls(self._analyzer, self._root = self._graph_action_factory(self._analyzer,
self.storage, self.storage,
self._task_action, self._task_action,
self._retry_action) self._retry_action)
self._compiled = True self._compiled = True
return return
class SingleThreadedActionEngine(ActionEngine): class SingleThreadedActionEngine(ActionEngine):
"""Engine that runs tasks in serial manner.""" """Engine that runs tasks in serial manner."""
_storage_cls = t_storage.SingleThreadedStorage _storage_factory = t_storage.SingleThreadedStorage
class MultiThreadedActionEngine(ActionEngine): class MultiThreadedActionEngine(ActionEngine):
"""Engine that runs tasks in parallel manner.""" """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) return executor.ParallelTaskExecutor(self._executor)
def __init__(self, flow, flow_detail, backend, conf, **kwargs): def __init__(self, flow, flow_detail, backend, conf, **kwargs):

View File

@@ -42,12 +42,13 @@ class EngineBase(object):
def storage(self): def storage(self):
"""The storage unit for this flow.""" """The storage unit for this flow."""
if self._storage is None: 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 return self._storage
@abc.abstractproperty @abc.abstractproperty
def _storage_cls(self): def _storage_factory(self):
"""Storage class that will be used to generate storage objects.""" """Storage factory that will be used to generate storage objects."""
@abc.abstractmethod @abc.abstractmethod
def compile(self): def compile(self):

View File

@@ -34,9 +34,9 @@ class WorkerBasedActionEngine(engine.ActionEngine):
:keyword transport_options: transport specific options :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: if self._executor is not None:
return self._executor return self._executor
return executor.WorkerTaskExecutor( return executor.WorkerTaskExecutor(