Files
deb-python-taskflow/taskflow/engines/action_engine/actions/base.py
Joshua Harlow 5996c8f25e Allow the storage unit to use the right scoping strategy
Instead of having the fetch arguments functions need to be
provided a scope walker to correctly find the right arguments,
which only the internals of the action engine know about
provide a default scope walker (that is the same one the
action engine internal uses) to the storage unit and have it be
the default strategy used so that users need not know how to
pass it in (which they should not care about).

This allows for users to fetch the same mapped arguments as the
internals of the engine will fetch.

Change-Id: I1beca532b2b7c7ad98b09265a0c4477658052d16
2015-03-11 19:13:52 -07:00

42 lines
1.2 KiB
Python

# -*- coding: utf-8 -*-
# Copyright (C) 2015 Yahoo! Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import abc
import six
from taskflow import states
#: Sentinel use to represent no-result (none can be a valid result...)
NO_RESULT = object()
#: States that are expected to/may have a result to save...
SAVE_RESULT_STATES = (states.SUCCESS, states.FAILURE)
@six.add_metaclass(abc.ABCMeta)
class Action(object):
"""An action that handles executing, state changes, ... of atoms."""
def __init__(self, storage, notifier):
self._storage = storage
self._notifier = notifier
@abc.abstractmethod
def handles(self, atom):
"""Checks if this action handles the provided atom."""