Skip to content

Toro Cloud Dev Center

Gloop icon

Invoke steps

The invoke step is used to invoke other services, Flux services, Spring bean methods, and compatible Java and Groovy services in Gloop. It borrows the Mapper view from the map step, meaning you can also set variable values, declare new variables, or unload them in invoke steps. This makes Gloop infinitely more powerful, because if there's anything you can't do in Gloop, you can do it in Flux, Java, or Groovy! This also means that you can reuse existing services by wrapping them in invoke steps in Gloop services to make managing your services and APIs easier.

The Mapper view for invoke steps has two mappers inside it. One is for mapping input variables (on the left hand side) for the service/code it will invoke, and the other is for mapping output variables from the invoked service (on the right hand side).

An invoke step's mappings, as seen in the Mapper view

An invoke step's mappings, as seen in the Mapper view

Mapper for invoke steps

When an invoke step is selected in the service editor, the Mapper view in Martini will show all of the available input and output variables for the service to be invoked, as well as the variables available in the current scope of the service. This is where you map variable values from the current scope of the service to the service to be invoked and add set expressions to the inputs of the service to be invoked. After the service has been invoked, Gloop will then map and set all of the variables on the Output side of the Mapper view.

For example, the mapper screenshot below:

Example invoke step's mappings shown in Mapper view

Example invoke step's mappings shown in Mapper view

... is the same as the following Groovy code:

// Invoke some code.
GloopModel output = TrackerMethods.searchTracker(trackerQuery, externalIds, documentTypeId, 'Error', 'CustomerX', 'Togo', 'now', null, null, null, null, null, 100, 2)
// Declare the searchResult variable and map (set) it.
GloopModel searchResult = output.searchResult
// Declare the numberOfResults variable and map (set) it.
int numberOfResults = output.searchResult.numFound

Annotating code to make it Gloop-friendly

Gloop has a nifty set of annotations that are used to decorate Groovy and Java code with metadata to make your code look even better in the Gloop UI (and easier to use whilst writing services).

Adding invoke steps

There are two ways to add an invoke step to your service:

  • Drag and drop the service you want to invoke from the Navigator view.
  • Use Martini's auto-complete feature (activated by pressing in the service editor), then start typing in the name of the service you want to invoke. Once you find your selection in the list, click on it or use the cursor keys to highlight it and then press .

Below is a GIF showing both ways:

Adding an invoke step to a service

Adding an invoke step to a service

Asynchronous invoke steps

Gloop has the ability to invoke steps asynchronously (in other words - in a separate thread), without waiting for the step to complete - it will continue executing the service while the asynchronous step is running in the background. When the Asynchronous property of the invoke step is true, a green badge will appear at the top right-hand side of the step's icon, and the output mapper will no longer appear.

Invoke steps with the asynchronous badge

Invoke steps with the asynchronous badge

The examples that ships with Martini also contains a demonstration service at asyncStep.AsyncStepDemo.gloop.

Map and declare in one fell swoop!

If you would like to map the output of an invoke step to a new variable, simply drag the variable to the output tree, whilst holding . This will declare the variable and map it for you in one step!

Declaring and mapping in one move

Declaring and mapping in one move

Opening a service used by an invoke step

You can open the service called by an invoke step by right-clicking the invoke step from the Step editor > Open Declaration. Another option is to press on the selected step to do the same. You can also do this using the Open Declaration button in the Properties view, which appears when the invoke step is selected.

If the service called is from the core package, then Martini will only show the service in the Navigator view.

Opening a referenced service from the Properties view