def _next_step_to_execute()

in message_flow/sagas/orchestration_simple_dsl/abstract_simple_saga_definition.py [0:0]


    def _next_step_to_execute(self, state: SagaExecutionState, data: Data) -> Provider:
        skipped: int = 0
        compensating: bool = state.compensating
        direction: int = -1 if compensating else +1

        currently_executing = state.currently_executing + direction

        while currently_executing >= 0 and currently_executing < len(self._steps):
            step: Step = self._steps[currently_executing]

            if step.has_compensation(data) if compensating else step.has_action(data):
                step_to_execute: ToExecute = self._make_step_to_execute(
                    skipped, compensating, step
                )
                return self._make_saga_actions_provider_from_step(
                    step_to_execute, data, state
                )
            else:
                skipped += 1

            currently_executing += direction

        return self._make_saga_actions_provider(
            self._make_end_state_saga_actions(state)
        )