Saltar al contenido

Subflujos de Flogo: Impulsando la Mantenibilidad de su Software

La reutilización es una de las capacidades más importantes en el desarrollo de aplicaciones y esto es algo que se ha implementado tan bien en Flogo Enterprise que te vas a sorprender de lo genial que es. Echemos un vistazo a los Subflujos de Flogo

En Flogo no existe el concepto de Subflujo cuando creas una aplicación, solo puedes crear flujos. Si recuerdas, el flujo se creó basado en Disparadores y Acciones:

Aplicación en términos de Flogo

Entonces, ¿qué es un subflujo en Flogo? Un flujo sin los disparadores. Así de simple. Entonces, ¿significa que necesito crear un nuevo flujo, pero eliminando cualquier disparador o usando un disparador especial para que esto pueda ser reutilizado en un flujo diferente? No. No es necesario.

Cualquier flujo puede ser reutilizado como subflujos tal cual. Solo cambia cuando lo invocas como un subflujo, los disparadores no se van a ejecutar. Así de simple. Así que sí, puedes reutilizar cualquier flujo que hayas creado sin hacer nada en absoluto. Veamos cómo

Recuerda la aplicación que creamos en el post anterior sobre GraphQL:

Tenemos un flujo llamado Mutation_asignUser donde necesitamos recopilar la información del usuario y la empresa, lo mismo que ya estábamos haciendo en los siguientes flujos Query_currentUser y Query_company. Entonces, ¿qué tan fácil es reutilizarlos? Echemos un vistazo a Mutation_asignUser con más detalle:

Mutation_asignUser con uso de subflujos resaltado 

En las actividades con el cuadro rojo alrededor es donde estamos llamando a nuestros “subflujos” y esto es tan fácil como incluir una actividad llamada “Iniciar un SubFlujo”

Esta actividad va a pedir el flujo, que podría ser cualquier flujo que tengas en tu aplicación (no se pueden incluir flujos de otras aplicaciones como subflujo)

Y una vez que selecciones el flujo, la entrada y salida se van a completar basándose en la interfaz del flujo. Muy fácil, ¿verdad?

¡Vamos a hackearlo! y empezar a crear más aplicaciones Flogo!!!!

Flogo Subflows: Boosting the Manteniability of Your Software

Reuse is one of the most important capabilities in Application Development and this is something that has been implemented so great in Flogo Enterprise that you’re going to be amazed how great it is. Let’s take a look at Flogo Subflows

In Flogo it doesn’t exist the concept of Subflow when you create an application, you only can create flows. If you remember Flow was created based on Triggers and Actions:

Application in terms of Flogo

So, what is subflow in Flogo? A Flow without the triggers. That simple. So, it means that I need to create a new flow, but removing any trigger or using a special trigger so this could be reused in a different flow? No. Not needed.

Any flow can be reused as subflows as is. Only change when you invoke it as a subflow the triggers are not going to be executed. That simple. So, yes, you can reuse any flow you’ve created without doing anything at all. Let’s see how

Remember the application that we’ve created in the past post about GraphQL:

We have a flow named Mutation_asignUser where we need to gather the info from the user and the company, the same thing we were already doing in the following flows Query_currentUser and Query_company. So, how easy is to reuse them? Let’s take a look at Mutation_asignUser in more detail:

Mutation_asignUser with highlighted subflows usage

In the activities with the red box around is where we’re calling our “subflows” and this is so easy as include an activity called “Start a SubFlow”

This activity is going to ask for the flow, that it could be any flow you have in your application (not flows from other applications can be included as subflow)

And once you select the flow, input and output are going to be populated based on the flow interface. So easy, right?

Let’s hack it! and start creating more Flogo apps!!!!

Etiquetas: