Make the atom class an abstract class

To enforce the already existing behavior that atoms
have execute and revert methods (this is already the
de-facto behavior with its subclasses) we might as
well have the atom class be abstract and have methods
execute() and revert() that need to be implemented
in subclasses (which they already are).

Change-Id: Idfc25a7c2b01f674a065e3f467607eba4ab89a26
This commit is contained in:
Joshua Harlow
2015-02-13 12:58:03 -08:00
parent 72a9c00625
commit 101a47fe92

View File

@@ -15,6 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.
import abc
from oslo_utils import reflection
import six
@@ -128,6 +130,7 @@ def _build_arg_mapping(atom_name, reqs, rebind_args, function, do_infer,
return required, optional
@six.add_metaclass(abc.ABCMeta)
class Atom(object):
"""An abstract flow atom that causes a flow to progress (in some manner).
@@ -205,6 +208,14 @@ class Atom(object):
"by this atom"
% dict(item=self.name, oo=sorted(out_of_order)))
@abc.abstractmethod
def execute(self, *args, **kwargs):
"""Executes this atom."""
@abc.abstractmethod
def revert(self, *args, **kwargs):
"""Reverts this atom (undoing any :meth:`execute` side-effects)."""
@property
def name(self):
"""A non-unique name for this atom (human readable)."""